未验证 提交 3b315248 编写于 作者: O openharmony_ci 提交者: Gitee

!21066 【翻译完成】#I7JH0O (20113+20651+16030)

Merge pull request !21066 from Annie_wang/PR20548
...@@ -38,11 +38,11 @@ Obtains an RDB store. This API uses an asynchronous callback to return the resul ...@@ -38,11 +38,11 @@ Obtains an RDB store. This API uses an asynchronous callback to return the resul
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------------------------------------------- | | ------------ | ------------------------------------------------- |
| 14800010 | Failed to open or delete database by invalid database path. | | 14800010 | Failed to open or delete database by invalid database path. |
| 14800011 | Failed to open database by database corrupted. | | 14800011 | Failed open database, database corrupted. |
| 14800000 | Inner error. | | 14800000 | The inner error is occurred. |
**Example** **Example**
...@@ -122,11 +122,11 @@ Obtains an RDB store. This API uses a promise to return the result. You can set ...@@ -122,11 +122,11 @@ Obtains an RDB store. This API uses a promise to return the result. You can set
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------------------------------------------- | | ------------ | ------------------------------------------------- |
| 14800010 | Failed to open or delete database by invalid database path. | | 14800010 | Failed to open or delete database by invalid database path. |
| 14800011 | Failed to open database by database corrupted. | | 14800011 | Failed open database, database corrupted. |
| 14800000 | Inner error. | | 14800000 | The inner error is occurred. |
**Example** **Example**
...@@ -198,10 +198,10 @@ Deletes an RDB store. This API uses an asynchronous callback to return the resul ...@@ -198,10 +198,10 @@ Deletes an RDB store. This API uses an asynchronous callback to return the resul
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------------------------------------------- | | ------------ | ------------------------------------------------- |
| 14800010 | Failed to open or delete database by invalid database path. | | 14800010 | Failed to open or delete database by invalid database path. |
| 14800000 | Inner error. | | 14800000 | The inner error is occurred. |
**Example** **Example**
...@@ -265,10 +265,10 @@ Deletes an RDB store. This API uses a promise to return the result. ...@@ -265,10 +265,10 @@ Deletes an RDB store. This API uses a promise to return the result.
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------------------------------------------- | | ------------ | ------------------------------------------------- |
| 14800010 | Failed to open or delete database by invalid database path. | | 14800010 | Failed to open or delete database by invalid database path. |
| 14800000 | Inner error. | | 14800000 | The inner error is occurred. |
**Example** **Example**
...@@ -378,22 +378,6 @@ Defines the subscription type. ...@@ -378,22 +378,6 @@ Defines the subscription type.
| Name | Value | Description | | Name | Value | Description |
| --------------------- | ---- | ------------------ | | --------------------- | ---- | ------------------ |
| SUBSCRIBE_TYPE_REMOTE | 0 | Subscribe to remote data changes.| | SUBSCRIBE_TYPE_REMOTE | 0 | Subscribe to remote data changes.|
| SUBSCRIBE_TYPE_CLOUD<sup>10+</sup> | 1 | Subscribe to cloud data changes.|
## ConflictResolution<sup>10+</sup>
Defines the resolution to use when **insert()** and **update()** conflict.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
| Name | Value | Description |
| -------------------- | ---- | ------------------------------------------------------------ |
| ON_CONFLICT_NONE | 0 | No operation is performed.|
| ON_CONFLICT_ROLLBACK | 1 | Abort the SQL statement and roll back the current transaction. |
| ON_CONFLICT_ABORT | 2 | Abort the current SQL statement and revert any changes made by the current SQL statement. However, the changes made by the previous SQL statement in the same transaction are retained and the transaction remains active.|
| ON_CONFLICT_FAIL | 3 | Abort the current SQL statement. The **FAIL** resolution does not revert previous changes made by the failed SQL statement or end the transaction.|
| ON_CONFLICT_IGNORE | 4 | Skip the rows that contain constraint violations and continue to process the subsequent rows of the SQL statement.|
| ON_CONFLICT_REPLACE | 5 | Delete pre-existing rows that cause the constraint violation before inserting or updating the current row, and continue to execute the command normally.|
## RdbPredicates ## RdbPredicates
...@@ -1257,23 +1241,6 @@ Provides APIs to manage an RDB store. ...@@ -1257,23 +1241,6 @@ Provides APIs to manage an RDB store.
Before using the APIs of this class, use [executeSql](#executesql) to initialize the database table structure and related data. Before using the APIs of this class, use [executeSql](#executesql) to initialize the database table structure and related data.
### Attributes<sup>10+</sup>
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
| Name | Type | Mandatory| Description |
| ------------ | ----------- | ---- | -------------------------------- |
| version<sup>10+</sup> | number | Yes | RDB store version, which is an integer greater than 0. |
**Example**
```js
// Set the RDB store version.
store.version = 3;
// Obtain the RDB store version.
console.info(`RdbStore version is ${store.version}`);
```
### insert ### insert
insert(table: string, values: ValuesBucket, callback: AsyncCallback&lt;number&gt;):void insert(table: string, values: ValuesBucket, callback: AsyncCallback&lt;number&gt;):void
...@@ -1290,15 +1257,6 @@ Inserts a row of data into a table. This API uses an asynchronous callback to re ...@@ -1290,15 +1257,6 @@ Inserts a row of data into a table. This API uses an asynchronous callback to re
| values | [ValuesBucket](#valuesbucket) | Yes | Row of data to insert. | | values | [ValuesBucket](#valuesbucket) | Yes | Row of data to insert. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.|
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit. |
| 14800000 | Inner error. |
**Example** **Example**
```js ```js
...@@ -1317,49 +1275,6 @@ store.insert("EMPLOYEE", valueBucket, function (err, rowId) { ...@@ -1317,49 +1275,6 @@ store.insert("EMPLOYEE", valueBucket, function (err, rowId) {
}) })
``` ```
### insert<sup>10+</sup>
insert(table: string, values: ValuesBucket, conflict: ConflictResolution, callback: AsyncCallback&lt;number&gt;):void
Inserts a row of data into a table. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------- | ---- | ---------------------------------------------------------- |
| table | string | Yes | Name of the target table. |
| values | [ValuesBucket](#valuesbucket) | Yes | Row of data to insert. |
| conflict | [ConflictResolution](#conflictresolution10) | Yes | Resolution used to resolve the conflict. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.|
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit. |
| 14800000 | Inner error. |
**Example**
```js
const valueBucket = {
"NAME": "Lisa",
"AGE": 18,
"SALARY": 100.5,
"CODES": new Uint8Array([1, 2, 3, 4, 5]),
};
store.insert("EMPLOYEE", valueBucket, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE, function (err, rowId) {
if (err) {
console.error(`Insert is failed, code is ${err.code},message is ${err.message}`);
return;
}
console.info(`Insert is successful, rowId = ${rowId}`);
})
```
### insert ### insert
...@@ -1388,8 +1303,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode ...@@ -1388,8 +1303,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | -------------------------------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit. | | 14800000 | The inner error is occurred. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -1408,53 +1322,6 @@ promise.then((rowId) => { ...@@ -1408,53 +1322,6 @@ promise.then((rowId) => {
}) })
``` ```
### insert<sup>10+</sup>
insert(table: string, values: ValuesBucket, conflict: ConflictResolution):Promise&lt;number&gt;
Inserts a row of data into a table. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------- | ---- | -------------------------- |
| table | string | Yes | Name of the target table. |
| values | [ValuesBucket](#valuesbucket) | Yes | Row of data to insert.|
| conflict | [ConflictResolution](#conflictresolution10) | Yes | Resolution used to resolve the conflict. |
**Return value**
| Type | Description |
| --------------------- | ------------------------------------------------- |
| Promise&lt;number&gt; | Promise used to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.|
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit. |
| 14800000 | Inner error. |
**Example**
```js
const valueBucket = {
"NAME": "Lisa",
"AGE": 18,
"SALARY": 100.5,
"CODES": new Uint8Array([1, 2, 3, 4, 5]),
};
let promise = store.insert("EMPLOYEE", valueBucket, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE);
promise.then((rowId) => {
console.info(`Insert is successful, rowId = ${rowId}`);
}).catch((err) => {
console.error(`Insert is failed, code is ${err.code},message is ${err.message}`);
})
```
### batchInsert ### batchInsert
...@@ -1478,8 +1345,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode ...@@ -1478,8 +1345,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | -------------------------------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit. | | 14800000 | The inner error is occurred. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -1540,8 +1406,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode ...@@ -1540,8 +1406,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | -------------------------------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit. | | 14800000 | The inner error is occurred. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -1590,14 +1455,14 @@ Updates data in the RDB store based on the specified **RdbPredicates** object. T ...@@ -1590,14 +1455,14 @@ Updates data in the RDB store based on the specified **RdbPredicates** object. T
| predicates | [RdbPredicates](#rdbpredicates) | Yes | Update conditions specified by the **RdbPredicates** object. | | predicates | [RdbPredicates](#rdbpredicates) | Yes | Update conditions specified by the **RdbPredicates** object. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the number of rows updated. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the number of rows updated. |
**Error codes** **Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | -------------------------------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit. | | 14800000 | The inner error is occurred. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -1619,51 +1484,6 @@ store.update(valueBucket, predicates, function (err, rows) { ...@@ -1619,51 +1484,6 @@ store.update(valueBucket, predicates, function (err, rows) {
}) })
``` ```
### update<sup>10+</sup>
update(values: ValuesBucket, predicates: RdbPredicates, conflict: ConflictResolution, callback: AsyncCallback&lt;number&gt;):void
Updates data in the RDB store based on the specified **RdbPredicates** object. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
| values | [ValuesBucket](#valuesbucket) | Yes | Rows of data to update in the RDB store. The key-value pair is associated with the column name in the target table.|
| predicates | [RdbPredicates](#rdbpredicates) | Yes | Update conditions specified by the **RdbPredicates** object. |
| conflict | [ConflictResolution](#conflictresolution10) | Yes | Resolution used to resolve the conflict. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the number of rows updated. |
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit. |
| 14800000 | Inner error. |
**Example**
```js
const valueBucket = {
"NAME": "Rose",
"AGE": 22,
"SALARY": 200.5,
"CODES": new Uint8Array([1, 2, 3, 4, 5]),
};
let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
predicates.equalTo("NAME", "Lisa");
store.update(valueBucket, predicates, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE, function (err, rows) {
if (err) {
console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
return;
}
console.info(`Updated row count: ${rows}`);
})
```
### update ### update
...@@ -1692,8 +1512,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode ...@@ -1692,8 +1512,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | -------------------------------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit. | | 14800000 | The inner error is occurred. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -1714,55 +1533,6 @@ promise.then(async (rows) => { ...@@ -1714,55 +1533,6 @@ promise.then(async (rows) => {
}) })
``` ```
### update<sup>10+</sup>
update(values: ValuesBucket, predicates: RdbPredicates, conflict: ConflictResolution):Promise&lt;number&gt;
Updates data based on the specified **RdbPredicates** object. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
| values | [ValuesBucket](#valuesbucket) | Yes | Rows of data to update in the RDB store. The key-value pair is associated with the column name in the target table.|
| predicates | [RdbPredicates](#rdbpredicates) | Yes | Update conditions specified by the **RdbPredicates** object. |
| conflict | [ConflictResolution](#conflictresolution10) | Yes | Resolution used to resolve the conflict. |
**Return value**
| Type | Description |
| --------------------- | ----------------------------------------- |
| Promise&lt;number&gt; | Promise used to return the number of rows updated.|
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit. |
| 14800000 | Inner error. |
**Example**
```js
const valueBucket = {
"NAME": "Rose",
"AGE": 22,
"SALARY": 200.5,
"CODES": new Uint8Array([1, 2, 3, 4, 5]),
};
let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
predicates.equalTo("NAME", "Lisa");
let promise = store.update(valueBucket, predicates, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE);
promise.then(async (rows) => {
console.info(`Updated row count: ${rows}`);
}).catch((err) => {
console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
})
```
### update ### update
...@@ -1791,8 +1561,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode ...@@ -1791,8 +1561,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | -------------------------------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit. | | 14800000 | The inner error is occurred. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -1847,8 +1616,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode ...@@ -1847,8 +1616,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | -------------------------------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit. | | 14800000 | The inner error is occurred. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -1891,8 +1659,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode ...@@ -1891,8 +1659,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | -------------------------------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit. | | 14800000 | The inner error is occurred. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -1934,8 +1701,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode ...@@ -1934,8 +1701,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | -------------------------------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit. | | 14800000 | The inner error is occurred. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -1976,8 +1742,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode ...@@ -1976,8 +1742,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | -------------------------------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit. | | 14800000 | The inner error is occurred. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -2025,8 +1790,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode ...@@ -2025,8 +1790,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | -------------------------------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit. | | 14800000 | The inner error is occurred. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -2062,9 +1826,9 @@ Queries data from the RDB store based on specified conditions. This API uses an ...@@ -2062,9 +1826,9 @@ Queries data from the RDB store based on specified conditions. This API uses an
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ---------------------------- | | ------------ | -------------------------------------------- |
| 14800000 | Inner error. | | 14800000 | The inner error is occurred. |
**Example** **Example**
...@@ -2076,17 +1840,8 @@ store.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function (err, ...@@ -2076,17 +1840,8 @@ store.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function (err,
console.error(`Query failed, code is ${err.code},message is ${err.message}`); console.error(`Query failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`); console.info(`ResultSet column names: ${resultSet.columnNames}`);
// resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0. console.info(`ResultSet column count: ${resultSet.columnCount}`);
while(resultSet.goToNextRow()) {
const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
}
// Release the dataset memory.
resultSet.close();
}) })
``` ```
...@@ -2105,20 +1860,20 @@ Queries data from the RDB store based on specified conditions. This API uses a p ...@@ -2105,20 +1860,20 @@ Queries data from the RDB store based on specified conditions. This API uses a p
| predicates | [RdbPredicates](#rdbpredicates) | Yes | Query conditions specified by the **RdbPredicates** object. | | predicates | [RdbPredicates](#rdbpredicates) | Yes | Query conditions specified by the **RdbPredicates** object. |
| columns | Array&lt;string&gt; | No | Columns to query. If this parameter is not specified, the query applies to all columns.| | columns | Array&lt;string&gt; | No | Columns to query. If this parameter is not specified, the query applies to all columns.|
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | ---------------------------- |
| 14800000 | Inner error. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------------------------------------------- | -------------------------------------------------- | | ------------------------------------------------------- | -------------------------------------------------- |
| Promise&lt;[ResultSet](#resultset)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.| | Promise&lt;[ResultSet](#resultset)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | -------------------------------------------- |
| 14800000 | The inner error is occurred. |
**Example** **Example**
```js ```js
...@@ -2126,17 +1881,8 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); ...@@ -2126,17 +1881,8 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
predicates.equalTo("NAME", "Rose"); predicates.equalTo("NAME", "Rose");
let promise = store.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]); let promise = store.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
promise.then((resultSet) => { promise.then((resultSet) => {
console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`); console.info(`ResultSet column names: ${resultSet.columnNames}`);
// resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0. console.info(`ResultSet column count: ${resultSet.columnCount}`);
while(resultSet.goToNextRow()) {
const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
}
// Release the dataset memory.
resultSet.close();
}).catch((err) => { }).catch((err) => {
console.error(`Query failed, code is ${err.code},message is ${err.message}`); console.error(`Query failed, code is ${err.code},message is ${err.message}`);
}) })
...@@ -2167,9 +1913,9 @@ Queries data from the RDB store based on specified conditions. This API uses an ...@@ -2167,9 +1913,9 @@ Queries data from the RDB store based on specified conditions. This API uses an
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ---------------------------- | | ------------ | -------------------------------------------- |
| 14800000 | Inner error. | | 14800000 | The inner error is occurred. |
**Example** **Example**
...@@ -2182,17 +1928,8 @@ store.query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], fu ...@@ -2182,17 +1928,8 @@ store.query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], fu
console.error(`Query failed, code is ${err.code},message is ${err.message}`); console.error(`Query failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`); console.info(`ResultSet column names: ${resultSet.columnNames}`);
// resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0. console.info(`ResultSet column count: ${resultSet.columnCount}`);
while(resultSet.goToNextRow()) {
const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
}
// Release the dataset memory.
resultSet.close();
}) })
``` ```
...@@ -2226,9 +1963,9 @@ Queries data from the RDB store based on specified conditions. This API uses a p ...@@ -2226,9 +1963,9 @@ Queries data from the RDB store based on specified conditions. This API uses a p
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ---------------------------- | | ------------ | -------------------------------------------- |
| 14800000 | Inner error. | | 14800000 | The inner error is occurred. |
**Example** **Example**
...@@ -2238,17 +1975,8 @@ let predicates = new dataSharePredicates.DataSharePredicates(); ...@@ -2238,17 +1975,8 @@ let predicates = new dataSharePredicates.DataSharePredicates();
predicates.equalTo("NAME", "Rose"); predicates.equalTo("NAME", "Rose");
let promise = store.query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]); let promise = store.query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
promise.then((resultSet) => { promise.then((resultSet) => {
console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`); console.info(`ResultSet column names: ${resultSet.columnNames}`);
// resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0. console.info(`ResultSet column count: ${resultSet.columnCount}`);
while(resultSet.goToNextRow()) {
const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
}
// Release the dataset memory.
resultSet.close();
}).catch((err) => { }).catch((err) => {
console.error(`Query failed, code is ${err.code},message is ${err.message}`); console.error(`Query failed, code is ${err.code},message is ${err.message}`);
}) })
...@@ -2280,9 +2008,9 @@ Queries data from the RDB store of a remote device based on specified conditions ...@@ -2280,9 +2008,9 @@ Queries data from the RDB store of a remote device based on specified conditions
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ---------------------------- | | ------------ | -------------------------------------------- |
| 14800000 | Inner error. | | 14800000 | The inner error is occurred. |
**Example** **Example**
...@@ -2309,17 +2037,8 @@ store.remoteQuery(deviceId, "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALAR ...@@ -2309,17 +2037,8 @@ store.remoteQuery(deviceId, "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALAR
console.error(`Failed to remoteQuery, code is ${err.code},message is ${err.message}`); console.error(`Failed to remoteQuery, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`); console.info(`ResultSet column names: ${resultSet.columnNames}`);
// resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0. console.info(`ResultSet column count: ${resultSet.columnCount}`);
while(resultSet.goToNextRow()) {
const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
}
// Release the dataset memory.
resultSet.close();
} }
) )
``` ```
...@@ -2355,9 +2074,9 @@ Queries data from the RDB store of a remote device based on specified conditions ...@@ -2355,9 +2074,9 @@ Queries data from the RDB store of a remote device based on specified conditions
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ---------------------------- | | ------------ | -------------------------------------------- |
| 14800000 | Inner error. | | 14800000 | The inner error is occurred. |
**Example** **Example**
...@@ -2380,17 +2099,8 @@ let predicates = new relationalStore.RdbPredicates('EMPLOYEE'); ...@@ -2380,17 +2099,8 @@ let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
predicates.greaterThan("id", 0); predicates.greaterThan("id", 0);
let promise = store.remoteQuery(deviceId, "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]); let promise = store.remoteQuery(deviceId, "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
promise.then((resultSet) => { promise.then((resultSet) => {
console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`); console.info(`ResultSet column names: ${resultSet.columnNames}`);
// resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0. console.info(`ResultSet column count: ${resultSet.columnCount}`);
while(resultSet.goToNextRow()) {
const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
}
// Release the dataset memory.
resultSet.close();
}).catch((err) => { }).catch((err) => {
console.error(`Failed to remoteQuery, code is ${err.code},message is ${err.message}`); console.error(`Failed to remoteQuery, code is ${err.code},message is ${err.message}`);
}) })
...@@ -2416,9 +2126,9 @@ Queries data using the specified SQL statement. This API uses an asynchronous ca ...@@ -2416,9 +2126,9 @@ Queries data using the specified SQL statement. This API uses an asynchronous ca
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ---------------------------- | | ------------ | -------------------------------------------- |
| 14800000 | Inner error. | | 14800000 | The inner error is occurred. |
**Example** **Example**
...@@ -2428,17 +2138,8 @@ store.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['s ...@@ -2428,17 +2138,8 @@ store.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['s
console.error(`Query failed, code is ${err.code},message is ${err.message}`); console.error(`Query failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`); console.info(`ResultSet column names: ${resultSet.columnNames}`);
// resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0. console.info(`ResultSet column count: ${resultSet.columnCount}`);
while(resultSet.goToNextRow()) {
const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
}
// Release the dataset memory.
resultSet.close();
}) })
``` ```
...@@ -2467,26 +2168,17 @@ Queries data using the specified SQL statement. This API uses a promise to retur ...@@ -2467,26 +2168,17 @@ Queries data using the specified SQL statement. This API uses a promise to retur
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ---------------------------- | | ------------ | -------------------------------------------- |
| 14800000 | Inner error. | | 14800000 | The inner error is occurred. |
**Example** **Example**
```js ```js
let promise = store.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = 'sanguo'"); let promise = store.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = 'sanguo'");
promise.then((resultSet) => { promise.then((resultSet) => {
console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`); console.info(`ResultSet column names: ${resultSet.columnNames}`);
// resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0. console.info(`ResultSet column count: ${resultSet.columnCount}`);
while(resultSet.goToNextRow()) {
const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
}
// Release the dataset memory.
resultSet.close();
}).catch((err) => { }).catch((err) => {
console.error(`Query failed, code is ${err.code},message is ${err.message}`); console.error(`Query failed, code is ${err.code},message is ${err.message}`);
}) })
...@@ -2514,8 +2206,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode ...@@ -2514,8 +2206,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | -------------------------------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit. | | 14800000 | The inner error is occurred. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -2557,8 +2248,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode ...@@ -2557,8 +2248,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | -------------------------------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit. | | 14800000 | The inner error is occurred. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -2586,8 +2276,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode ...@@ -2586,8 +2276,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | -------------------------------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit. | | 14800000 | The inner error is occurred. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -2708,9 +2397,9 @@ Backs up an RDB store. This API uses an asynchronous callback to return the resu ...@@ -2708,9 +2397,9 @@ Backs up an RDB store. This API uses an asynchronous callback to return the resu
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ---------------------------- | | ------------ | -------------------------------------------- |
| 14800000 | Inner error. | | 14800000 | The inner error is occurred. |
**Example** **Example**
...@@ -2738,20 +2427,20 @@ Backs up an RDB store. This API uses a promise to return the result. ...@@ -2738,20 +2427,20 @@ Backs up an RDB store. This API uses a promise to return the result.
| -------- | ------ | ---- | ------------------------ | | -------- | ------ | ---- | ------------------------ |
| destName | string | Yes | Name of the RDB store backup file.| | destName | string | Yes | Name of the RDB store backup file.|
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | -------------------------------------------- |
| 14800000 | The inner error is occurred. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ------------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | ---------------------------- |
| 14800000 | Inner error. |
**Example** **Example**
```js ```js
...@@ -2782,9 +2471,9 @@ Restores an RDB store from a backup file. This API uses an asynchronous callback ...@@ -2782,9 +2471,9 @@ Restores an RDB store from a backup file. This API uses an asynchronous callback
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ---------------------------- | | ------------ | -------------------------------------------- |
| 14800000 | Inner error. | | 14800000 | The inner error is occurred. |
**Example** **Example**
...@@ -2822,9 +2511,9 @@ Restores an RDB store from a backup file. This API uses a promise to return the ...@@ -2822,9 +2511,9 @@ Restores an RDB store from a backup file. This API uses a promise to return the
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ---------------------------- | | ------------ | -------------------------------------------- |
| 14800000 | Inner error. | | 14800000 | The inner error is occurred. |
**Example** **Example**
...@@ -2858,9 +2547,9 @@ Sets distributed tables. This API uses an asynchronous callback to return the re ...@@ -2858,9 +2547,9 @@ Sets distributed tables. This API uses an asynchronous callback to return the re
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ---------------------------- | | ------------ | -------------------------------------------- |
| 14800000 | Inner error. | | 14800000 | The inner error is occurred. |
**Example** **Example**
...@@ -2900,9 +2589,9 @@ Sets distributed tables. This API uses a promise to return the result. ...@@ -2900,9 +2589,9 @@ Sets distributed tables. This API uses a promise to return the result.
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ---------------------------- | | ------------ | -------------------------------------------- |
| 14800000 | Inner error. | | 14800000 | The inner error is occurred. |
**Example** **Example**
...@@ -2921,7 +2610,7 @@ obtainDistributedTableName(device: string, table: string, callback: AsyncCallbac ...@@ -2921,7 +2610,7 @@ obtainDistributedTableName(device: string, table: string, callback: AsyncCallbac
Obtains the distributed table name of a remote device based on the local table name of the device. The distributed table name is required when the RDB store of a remote device is queried. Obtains the distributed table name of a remote device based on the local table name of the device. The distributed table name is required when the RDB store of a remote device is queried.
> **NOTE** > **NOTE**<br/>
> >
> The value of **device** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. > The value of **device** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
...@@ -2941,9 +2630,9 @@ Obtains the distributed table name of a remote device based on the local table n ...@@ -2941,9 +2630,9 @@ Obtains the distributed table name of a remote device based on the local table n
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ---------------------------- | | ------------ | -------------------------------------------- |
| 14800000 | Inner error. | | 14800000 | The inner error is occurred. |
**Example** **Example**
...@@ -2977,7 +2666,7 @@ store.obtainDistributedTableName(deviceId, "EMPLOYEE", function (err, tableName) ...@@ -2977,7 +2666,7 @@ store.obtainDistributedTableName(deviceId, "EMPLOYEE", function (err, tableName)
Obtains the distributed table name of a remote device based on the local table name of the device. The distributed table name is required when the RDB store of a remote device is queried. Obtains the distributed table name of a remote device based on the local table name of the device. The distributed table name is required when the RDB store of a remote device is queried.
> **NOTE** > **NOTE**<br/>
> >
> The value of **device** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. > The value of **device** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
...@@ -3002,9 +2691,9 @@ Obtains the distributed table name of a remote device based on the local table n ...@@ -3002,9 +2691,9 @@ Obtains the distributed table name of a remote device based on the local table n
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ---------------------------- | | ------------ | -------------------------------------------- |
| 14800000 | Inner error. | | 14800000 | The inner error is occurred. |
**Example** **Example**
...@@ -3053,9 +2742,9 @@ Synchronizes data between devices. This API uses an asynchronous callback to ret ...@@ -3053,9 +2742,9 @@ Synchronizes data between devices. This API uses an asynchronous callback to ret
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ---------------------------- | | ------------ | -------------------------------------------- |
| 14800000 | Inner error. | | 14800000 | The inner error is occurred. |
**Example** **Example**
...@@ -3117,9 +2806,9 @@ Synchronizes data between devices. This API uses a promise to return the result. ...@@ -3117,9 +2806,9 @@ Synchronizes data between devices. This API uses a promise to return the result.
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ---------------------------- | | ------------ | -------------------------------------------- |
| 14800000 | Inner error. | | 14800000 | The inner error is occurred. |
**Example** **Example**
...@@ -3188,7 +2877,7 @@ try { ...@@ -3188,7 +2877,7 @@ try {
off(event:'dataChange', type: SubscribeType, observer: Callback&lt;Array&lt;string&gt;&gt;): void off(event:'dataChange', type: SubscribeType, observer: Callback&lt;Array&lt;string&gt;&gt;): void
Unregisters the observer of the specified type from the RDB store. Unregisters the observer of the specified type.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
......
...@@ -8,8 +8,6 @@ The **DataStorage** module provides applications with data processing capability ...@@ -8,8 +8,6 @@ The **DataStorage** module provides applications with data processing capability
> - The initial APIs of this module are supported since API version 6. 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 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> >
> - The APIs of this module are no longer maintained since API version 9. You are advised to use [@ohos.data.preferences](js-apis-data-preferences.md). > - The APIs of this module are no longer maintained since API version 9. You are advised to use [@ohos.data.preferences](js-apis-data-preferences.md).
>
> - The APIs of this module can be used only in the FA model.
## Modules to Import ## Modules to Import
...@@ -188,7 +186,7 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete ...@@ -188,7 +186,7 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | -------------------------- | | -------- | ------------------------- | ---- | -------------------------- |
| path | string | Yes | Path of the target file.| | path | string | Yes | Path of the target file.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value. |
**Example** **Example**
...@@ -230,7 +228,7 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete ...@@ -230,7 +228,7 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete
| Type | Description | | Type | Description |
| ------------------- | ------------------------------- | | ------------------- | ------------------------------- |
| Promise&lt;void&gt; | Promise that returns no value. | | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -295,7 +293,7 @@ Removes the singleton **Storage** instance of a file from the cache. The removed ...@@ -295,7 +293,7 @@ Removes the singleton **Storage** instance of a file from the cache. The removed
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | -------------------------- | | -------- | ------------------------- | ---- | -------------------------- |
| path | string | Yes | Path of the target file.| | path | string | Yes | Path of the target file.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value. |
**Example** **Example**
...@@ -337,7 +335,7 @@ Removes the singleton **Storage** instance of a file from the cache. The removed ...@@ -337,7 +335,7 @@ Removes the singleton **Storage** instance of a file from the cache. The removed
| Type | Description | | Type | Description |
| ------------------- | ------------------------------- | | ------------------- | ------------------------------- |
| Promise&lt;void&gt; | Promise that returns no value. | | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -490,7 +488,7 @@ Obtains the **Storage** instance corresponding to the specified file, writes dat ...@@ -490,7 +488,7 @@ Obtains the **Storage** instance corresponding to the specified file, writes dat
| -------- | ------------------------- | ---- | ----------------------------------------- | | -------- | ------------------------- | ---- | ----------------------------------------- |
| key | string | Yes | Key of the data. It cannot be empty. | | key | string | Yes | Key of the data. It cannot be empty. |
| value | [ValueType](#valuetype) | Yes | New value to store. It can be a number, string, or Boolean value.| | value | [ValueType](#valuetype) | Yes | New value to store. It can be a number, string, or Boolean value.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value. |
**Example** **Example**
...@@ -524,7 +522,7 @@ Obtains the **Storage** instance corresponding to the specified file, writes dat ...@@ -524,7 +522,7 @@ Obtains the **Storage** instance corresponding to the specified file, writes dat
| Type | Description | | Type | Description |
| ------------------- | --------------------------- | | ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise that returns no value. | | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -672,7 +670,7 @@ Deletes data with the specified key from this storage object. This API uses an a ...@@ -672,7 +670,7 @@ Deletes data with the specified key from this storage object. This API uses an a
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------------------- | | -------- | ------------------------- | ---- | ------------------------------- |
| key | string | Yes | Key of the data. It cannot be empty.| | key | string | Yes | Key of the data. It cannot be empty.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value. |
**Example** **Example**
...@@ -705,7 +703,7 @@ Deletes data with the specified key from this storage object. This API uses a pr ...@@ -705,7 +703,7 @@ Deletes data with the specified key from this storage object. This API uses a pr
| Type | Description | | Type | Description |
| ------------------- | --------------------------- | | ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise that returns no value. | | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -746,7 +744,7 @@ Saves the modification of this object to the **Storage** instance and synchroniz ...@@ -746,7 +744,7 @@ Saves the modification of this object to the **Storage** instance and synchroniz
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- | | -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value.|
**Example** **Example**
...@@ -773,7 +771,7 @@ Saves the modification of this object to the **Storage** instance and synchroniz ...@@ -773,7 +771,7 @@ Saves the modification of this object to the **Storage** instance and synchroniz
| Type | Description | | Type | Description |
| ------------------- | --------------------------- | | ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise that returns no value. | | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -814,7 +812,7 @@ Clears this **Storage** object. This API uses an asynchronous callback to return ...@@ -814,7 +812,7 @@ Clears this **Storage** object. This API uses an asynchronous callback to return
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- | | -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value.|
**Example** **Example**
...@@ -840,7 +838,7 @@ Clears this **Storage** object. This API uses a promise to return the result. ...@@ -840,7 +838,7 @@ Clears this **Storage** object. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | --------------------------- | | ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise that returns no value. | | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
......
...@@ -247,7 +247,7 @@ Obtains the data size of this **MessageSequence** object. ...@@ -247,7 +247,7 @@ Obtains the data size of this **MessageSequence** object.
| Type | Description | | Type | Description |
| ------ | ----------------------------------------------- | | ------ | ----------------------------------------------- |
| number | Size of the **MessageSequence** object obtained, in bytes.| | number | Size of the **MessageSequence** instance obtained, in bytes.|
**Example** **Example**
...@@ -293,6 +293,14 @@ Sets the size of the data contained in this **MessageSequence** object. ...@@ -293,6 +293,14 @@ Sets the size of the data contained in this **MessageSequence** object.
| ------ | ------ | ---- | ------ | | ------ | ------ | ---- | ------ |
| size | number | Yes | Data size to set, in bytes.| | size | number | Yes | Data size to set, in bytes.|
**Error codes**
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message|
| -------- | -------- |
| 1900009 | write data to message sequence failed |
**Example** **Example**
```ts ```ts
...@@ -326,6 +334,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -326,6 +334,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 1900009 | write data to message sequence failed |
| 1900011 | parcel memory alloc failed | | 1900011 | parcel memory alloc failed |
**Example** **Example**
...@@ -452,6 +461,12 @@ Moves the read pointer to the specified position. ...@@ -452,6 +461,12 @@ Moves the read pointer to the specified position.
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| pos | number | Yes | Position from which data is to read.| | pos | number | Yes | Position from which data is to read.|
**Error codes**
| ID| Error Message|
| -------- | -------- |
| 1900010 | read data from message sequence failed |
**Example** **Example**
```ts ```ts
...@@ -484,6 +499,12 @@ Moves the write pointer to the specified position. ...@@ -484,6 +499,12 @@ Moves the write pointer to the specified position.
| ------ | ------ | ---- | ----- | | ------ | ------ | ---- | ----- |
| pos | number | Yes | Position from which data is to write.| | pos | number | Yes | Position from which data is to write.|
**Error codes**
| ID| Error Message|
| -------- | -------- |
| 1900009 | write data to message sequence failed |
**Example** **Example**
```ts ```ts
...@@ -2701,7 +2722,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2701,7 +2722,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
super(descriptor); super(descriptor);
this.modifyLocalInterface(this, descriptor); this.modifyLocalInterface(this, descriptor);
} }
asObject(): rpc.IRemoteObject { asObject(): rpc.IRemoteObject {
return this; return this;
} }
...@@ -2718,7 +2739,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2718,7 +2739,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
} }
``` ```
### closeFileDescriptor<sup>9+</sup> ### closeFileDescriptor<sup>9+</sup>
static closeFileDescriptor(fd: number): void static closeFileDescriptor(fd: number): void
...@@ -2805,7 +2825,6 @@ Checks whether this **MessageSequence** object contains file descriptors. ...@@ -2805,7 +2825,6 @@ Checks whether this **MessageSequence** object contains file descriptors.
**Example** **Example**
```ts ```ts
import fs from '@ohos.file.fs'; import fs from '@ohos.file.fs';
let sequence = new rpc.MessageSequence(); let sequence = new rpc.MessageSequence();
...@@ -2926,8 +2945,8 @@ Writes an anonymous shared object to this **MessageSequence** object. ...@@ -2926,8 +2945,8 @@ Writes an anonymous shared object to this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| -------- | ------- | | -------- | -------- |
| 1900003 | write to ashmem failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
...@@ -2948,7 +2967,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2948,7 +2967,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
} }
``` ```
### readAshmem ### readAshmem
readAshmem(): Ashmem readAshmem(): Ashmem
...@@ -2969,7 +2987,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2969,7 +2987,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 1900004 | read from ashmem failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -3263,7 +3281,6 @@ Writes an interface token to this **MessageParcel** object. The remote object ca ...@@ -3263,7 +3281,6 @@ Writes an interface token to this **MessageParcel** object. The remote object ca
console.log("RpcServer: writeInterfaceToken is " + result); console.log("RpcServer: writeInterfaceToken is " + result);
``` ```
### readInterfaceToken ### readInterfaceToken
readInterfaceToken(): string readInterfaceToken(): string
...@@ -3672,7 +3689,7 @@ Writes an Int value to this **MessageParcel** object. ...@@ -3672,7 +3689,7 @@ Writes an Int value to this **MessageParcel** object.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ----------------------------- | | ------- | ----------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
...@@ -5825,7 +5842,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -5825,7 +5842,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- | | ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | code | number | Yes | Message code (1-16777215) called by the request, which is determined by the communication parties. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.|
| data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. |
| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. |
| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. |
...@@ -5836,7 +5853,6 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -5836,7 +5853,6 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
| ------- | -------------------------------- | | ------- | -------------------------------- |
| boolean | Returns **true** if the message is sent successfully; returns **false** otherwise.| | boolean | Returns **true** if the message is sent successfully; returns **false** otherwise.|
### sendRequest<sup>8+(deprecated)</sup> ### sendRequest<sup>8+(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [sendMessageRequest](#sendmessagerequest9). >This API is no longer maintained since API version 9. You are advised to use [sendMessageRequest](#sendmessagerequest9).
...@@ -5851,7 +5867,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -5851,7 +5867,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ---------------------------------------- | ---- | -------------------------------------------------------------------------------------- | | ------- | ---------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | code | number | Yes | Message code (1-16777215) called by the request, which is determined by the communication parties. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.|
| data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. |
| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. |
| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. |
...@@ -5862,7 +5878,6 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -5862,7 +5878,6 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
| -------------------------------- | --------------------------------------------- | | -------------------------------- | --------------------------------------------- |
| Promise&lt;SendRequestResult&gt; | Promise used to return the **sendRequestResult** object.| | Promise&lt;SendRequestResult&gt; | Promise used to return the **sendRequestResult** object.|
### sendMessageRequest<sup>9+</sup> ### sendMessageRequest<sup>9+</sup>
sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption): Promise&lt;RequestResult&gt; sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption): Promise&lt;RequestResult&gt;
...@@ -5875,7 +5890,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -5875,7 +5890,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- | | ------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- |
| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | code | number | Yes | Message code (1-16777215) called by the request, which is determined by the communication parties. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.|
| data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. | | data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. |
| reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. | | reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. |
| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. |
...@@ -5886,7 +5901,6 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -5886,7 +5901,6 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
| ---------------------------- | ----------------------------------------- | | ---------------------------- | ----------------------------------------- |
| Promise&lt;RequestResult&gt; | Promise used to return the **requestResult** object.| | Promise&lt;RequestResult&gt; | Promise used to return the **requestResult** object.|
### sendMessageRequest<sup>9+</sup> ### sendMessageRequest<sup>9+</sup>
sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption, callback: AsyncCallback&lt;RequestResult&gt;): void sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption, callback: AsyncCallback&lt;RequestResult&gt;): void
...@@ -5899,7 +5913,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -5899,7 +5913,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- | | -------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- |
| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | code | number | Yes | Message code (1-16777215) called by the request, which is determined by the communication parties. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.|
| data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. | | data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. |
| reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. | | reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. |
| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. |
...@@ -5919,7 +5933,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -5919,7 +5933,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- | | -------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | code | number | Yes | Message code (1-16777215) called by the request, which is determined by the communication parties. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.|
| data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. |
| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. |
| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. |
...@@ -5946,7 +5960,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -5946,7 +5960,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 1900008 | proxy or remote object is invalid | | 1900005 | only proxy object permitted |
### addDeathrecipient<sup>(deprecated)</sup> ### addDeathrecipient<sup>(deprecated)</sup>
...@@ -5971,7 +5985,6 @@ Adds a callback for receiving death notifications of the remote object. This met ...@@ -5971,7 +5985,6 @@ Adds a callback for receiving death notifications of the remote object. This met
| ------- | ---------------------------------------- | | ------- | ---------------------------------------- |
| boolean | Returns **true** if the callback is added successfully; returns **false** otherwise.| | boolean | Returns **true** if the callback is added successfully; returns **false** otherwise.|
### unregisterDeathRecipient<sup>9+</sup> ### unregisterDeathRecipient<sup>9+</sup>
unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void
...@@ -5993,7 +6006,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -5993,7 +6006,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 1900008 | proxy or remote object is invalid | | 1900005 | only proxy object permitted |
### removeDeathRecipient<sup>(deprecated)</sup> ### removeDeathRecipient<sup>(deprecated)</sup>
...@@ -6040,7 +6053,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -6040,7 +6053,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
| -------- | -------- | | -------- | -------- |
| 1900008 | proxy or remote object is invalid | | 1900008 | proxy or remote object is invalid |
### getInterfaceDescriptor<sup>(deprecated)</sup> ### getInterfaceDescriptor<sup>(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [getDescriptor](#getdescriptor9). >This API is no longer maintained since API version 9. You are advised to use [getDescriptor](#getdescriptor9).
...@@ -6057,7 +6069,6 @@ Obtains the interface descriptor (which is a string) of this object. ...@@ -6057,7 +6069,6 @@ Obtains the interface descriptor (which is a string) of this object.
| ------ | ---------------- | | ------ | ---------------- |
| string | Interface descriptor obtained.| | string | Interface descriptor obtained.|
### isObjectDead ### isObjectDead
isObjectDead(): boolean isObjectDead(): boolean
...@@ -6072,7 +6083,6 @@ Checks whether this object is dead. ...@@ -6072,7 +6083,6 @@ Checks whether this object is dead.
| ------- | ---------------------------------- | | ------- | ---------------------------------- |
| boolean | Returns **true** if the object is dead; returns **false** otherwise.| | boolean | Returns **true** if the object is dead; returns **false** otherwise.|
## RemoteProxy ## RemoteProxy
Provides APIs to implement **IRemoteObject**. Provides APIs to implement **IRemoteObject**.
...@@ -6101,7 +6111,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -6101,7 +6111,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- | | ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | code | number | Yes | Message code (1-16777215) called by the request, which is determined by the communication parties. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.|
| data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. |
| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. |
| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. |
...@@ -6177,7 +6187,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -6177,7 +6187,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- | | ------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- |
| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | code | number | Yes | Message code (1-16777215) called by the request, which is determined by the communication parties. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.|
| data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. | | data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. |
| reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. | | reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. |
| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. |
...@@ -6261,7 +6271,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -6261,7 +6271,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- | | ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | code | number | Yes | Message code (1-16777215) called by the request, which is determined by the communication parties. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.|
| data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. |
| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. |
| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. |
...@@ -6343,7 +6353,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -6343,7 +6353,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- | | -------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- |
| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | code | number | Yes | Message code (1-16777215) called by the request, which is determined by the communication parties. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.|
| data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. | | data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. |
| reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. | | reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. |
| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. |
...@@ -6424,7 +6434,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -6424,7 +6434,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- | | -------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | code | number | Yes | Message code (1-16777215) called by the request, which is determined by the communication parties. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.|
| data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. |
| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. |
| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. |
...@@ -7079,13 +7089,12 @@ Provides common message options (flag and wait time). Use the specified flag to ...@@ -7079,13 +7089,12 @@ Provides common message options (flag and wait time). Use the specified flag to
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
| Name | Value | Description | | Name | Value | Description |
| ------------- | ---- | ----------------------------------------------------------- | | ------------- | --------- | ----------------------------------------------------------- |
| TF_SYNC | 0 | Synchronous call. | | TF_SYNC | 0 (0x00) | Synchronous call. |
| TF_ASYNC | 1 | Asynchronous call. | | TF_ASYNC | 1 (0x01) | Asynchronous call. |
| TF_ACCEPT_FDS | 0x10 | Indication to **sendMessageRequest<sup>9+</sup>** for returning the file descriptor.| | TF_ACCEPT_FDS | 16 (0x10) | Indication to **sendMessageRequest<sup>9+</sup>** for returning the file descriptor.|
| TF_WAIT_TIME | 8 | Default waiting time, in seconds. | | TF_WAIT_TIME | 4 (0x4) | Default waiting time, in seconds. |
### constructor<sup>9+</sup> ### constructor<sup>9+</sup>
...@@ -7101,7 +7110,6 @@ A constructor used to create a **MessageOption** object. ...@@ -7101,7 +7110,6 @@ A constructor used to create a **MessageOption** object.
| ------ | ------- | ---- | -------------------------------------- | | ------ | ------- | ---- | -------------------------------------- |
| async | boolean | No | Call flag, which can be synchronous or asynchronous. The default value is **synchronous**.| | async | boolean | No | Call flag, which can be synchronous or asynchronous. The default value is **synchronous**.|
**Example** **Example**
```ts ```ts
...@@ -7391,7 +7399,6 @@ Obtains the caller's token ID, which is used to verify the caller identity. ...@@ -7391,7 +7399,6 @@ Obtains the caller's token ID, which is used to verify the caller identity.
} }
``` ```
### getCallingDeviceID ### getCallingDeviceID
static getCallingDeviceID(): string static getCallingDeviceID(): string
...@@ -7484,7 +7491,6 @@ Flushes all suspended commands from the specified **RemoteProxy** to the corresp ...@@ -7484,7 +7491,6 @@ Flushes all suspended commands from the specified **RemoteProxy** to the corresp
| ------ | ------------------------------- | ---- | ------------------- | | ------ | ------------------------------- | ---- | ------------------- |
| object | [IRemoteObject](#iremoteobject) | Yes | **RemoteProxy** specified. | | object | [IRemoteObject](#iremoteobject) | Yes | **RemoteProxy** specified. |
**Example** **Example**
```ts ```ts
...@@ -7577,7 +7583,6 @@ Changes the UID and PID of the remote user to the UID and PID of the local user. ...@@ -7577,7 +7583,6 @@ Changes the UID and PID of the remote user to the UID and PID of the local user.
} }
``` ```
### restoreCallingIdentity<sup>9+</sup> ### restoreCallingIdentity<sup>9+</sup>
static restoreCallingIdentity(identity: string): void static restoreCallingIdentity(identity: string): void
...@@ -7667,7 +7672,6 @@ A constructor used to create a **RemoteObject** object. ...@@ -7667,7 +7672,6 @@ A constructor used to create a **RemoteObject** object.
| ---------- | ------ | ---- | ------------ | | ---------- | ------ | ---- | ------------ |
| descriptor | string | Yes | Interface descriptor.| | descriptor | string | Yes | Interface descriptor.|
### sendRequest<sup>(deprecated)</sup> ### sendRequest<sup>(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [sendMessageRequest](#sendmessagerequest9). >This API is no longer maintained since API version 9. You are advised to use [sendMessageRequest](#sendmessagerequest9).
...@@ -7682,7 +7686,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -7682,7 +7686,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- | | ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | code | number | Yes | Message code (1-16777215) called by the request, which is determined by the communication parties. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.|
| data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. |
| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. |
| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. |
...@@ -7748,7 +7752,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -7748,7 +7752,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- | | ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | code | number | Yes | Message code (1-16777215) called by the request, which is determined by the communication parties. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.|
| data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. |
| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. |
| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. |
...@@ -7818,7 +7822,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -7818,7 +7822,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- | | ------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- |
| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | code | number | Yes | Message code (1-16777215) called by the request, which is determined by the communication parties. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.|
| data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. | | data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. |
| reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. | | reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. |
| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. |
...@@ -7874,7 +7878,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -7874,7 +7878,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- | | ------------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- |
| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | code | number | Yes | Message code (1-16777215) called by the request, which is determined by the communication parties. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.|
| data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. | | data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. |
| reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. | | reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. |
| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. |
...@@ -7924,7 +7928,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -7924,7 +7928,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- | | ------------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | code | number | Yes | Message code (1-16777215) called by the request, which is determined by the communication parties. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.|
| data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. |
| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. |
| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. |
...@@ -8239,7 +8243,6 @@ Obtains the interface descriptor. ...@@ -8239,7 +8243,6 @@ Obtains the interface descriptor.
| ------------- | --------------------------------------------- | | ------------- | --------------------------------------------- |
| IRemoteBroker | **IRemoteBroker** object bound to the specified interface token.| | IRemoteBroker | **IRemoteBroker** object bound to the specified interface token.|
**Example** **Example**
```ts ```ts
...@@ -8612,7 +8615,6 @@ Creates an **Ashmem** object by copying the file descriptor of an existing **Ash ...@@ -8612,7 +8615,6 @@ Creates an **Ashmem** object by copying the file descriptor of an existing **Ash
| ------ | ---------------------- | | ------ | ---------------------- |
| Ashmem | **Ashmem** object created.| | Ashmem | **Ashmem** object created.|
**Example** **Example**
```ts ```ts
......
# WLAN # @ohos.wifiManager (WLAN)
The **WLAN** module provides basic wireless local area network (WLAN) functions, peer-to-peer (P2P) functions, and WLAN message notification services. It allows applications to communicate with other devices over WLAN. The **WLAN** module provides basic wireless local area network (WLAN) functions, peer-to-peer (P2P) functions, and WLAN message notification services. It allows applications to communicate with other devices over WLAN.
> **NOTE** > **NOTE**
...@@ -31,6 +30,14 @@ Enables WLAN. ...@@ -31,6 +30,14 @@ Enables WLAN.
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.disableWifi<sup>9+</sup> ## wifi.disableWifi<sup>9+</sup>
...@@ -50,6 +57,13 @@ Disables WLAN. ...@@ -50,6 +57,13 @@ Disables WLAN.
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.isWifiActive<sup>9+</sup> ## wifi.isWifiActive<sup>9+</sup>
...@@ -67,6 +81,13 @@ Checks whether WLAN is enabled. ...@@ -67,6 +81,13 @@ Checks whether WLAN is enabled.
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if WLAN is enabled; returns **false** otherwise.| | boolean | Returns **true** if WLAN is enabled; returns **false** otherwise.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.scan<sup>9+</sup> ## wifi.scan<sup>9+</sup>
...@@ -74,7 +95,7 @@ scan(): void ...@@ -74,7 +95,7 @@ scan(): void
Starts a scan for WLAN. Starts a scan for WLAN.
**Required permissions**: **ohos.permission.SET_WIFI_INFO** and **ohos.permission.LOCATION** **Required permissions**: ohos.permission.SET_WIFI_INFO and ohos.permission.LOCATION
**System capability**: SystemCapability.Communication.WiFi.STA **System capability**: SystemCapability.Communication.WiFi.STA
...@@ -84,6 +105,13 @@ Starts a scan for WLAN. ...@@ -84,6 +105,13 @@ Starts a scan for WLAN.
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.getScanResults<sup>9+</sup> ## wifi.getScanResults<sup>9+</sup>
...@@ -101,6 +129,13 @@ Obtains the scan result. This API uses a promise to return the result. ...@@ -101,6 +129,13 @@ Obtains the scan result. This API uses a promise to return the result.
| -------- | -------- | | -------- | -------- |
| Promise&lt;&nbsp;Array&lt;[WifiScanInfo](#wifiscaninfo)&gt;&nbsp;&gt; | Promise used to return the detected hotspots.| | Promise&lt;&nbsp;Array&lt;[WifiScanInfo](#wifiscaninfo)&gt;&nbsp;&gt; | Promise used to return the detected hotspots.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.getScanResults<sup>9+</sup> ## wifi.getScanResults<sup>9+</sup>
...@@ -118,6 +153,14 @@ Obtains the scan result. This API uses an asynchronous callback to return the re ...@@ -118,6 +153,14 @@ Obtains the scan result. This API uses an asynchronous callback to return the re
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;&nbsp;Array&lt;[WifiScanInfo](#wifiscaninfo)&gt;&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the detected hotspots. Otherwise, **err** is a non-zero value and **data** is empty.| | callback | AsyncCallback&lt;&nbsp;Array&lt;[WifiScanInfo](#wifiscaninfo)&gt;&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the detected hotspots. Otherwise, **err** is a non-zero value and **data** is empty.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
**Example** **Example**
```js ```js
import wifi from '@ohos.wifi'; import wifi from '@ohos.wifi';
...@@ -251,6 +294,13 @@ Obtains the scan result. This API returns the result synchronously. ...@@ -251,6 +294,13 @@ Obtains the scan result. This API returns the result synchronously.
| -------- | -------- | | -------- | -------- |
| &nbsp;Array&lt;[WifiScanInfo](#wifiscaninfo)&gt; | Scan result obtained.| | &nbsp;Array&lt;[WifiScanInfo](#wifiscaninfo)&gt; | Scan result obtained.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.addDeviceConfig<sup>9+</sup> ## wifi.addDeviceConfig<sup>9+</sup>
...@@ -276,6 +326,14 @@ Adds network configuration. This API uses a promise to return the result. ...@@ -276,6 +326,14 @@ Adds network configuration. This API uses a promise to return the result.
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the ID of the added network configuration. If **-1** is returned, the network configuration fails to be added.| | Promise&lt;number&gt; | Promise used to return the ID of the added network configuration. If **-1** is returned, the network configuration fails to be added.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## WifiDeviceConfig<sup>9+</sup> ## WifiDeviceConfig<sup>9+</sup>
Represents the WLAN configuration. Represents the WLAN configuration.
...@@ -351,6 +409,8 @@ Represents EAP configuration information. ...@@ -351,6 +409,8 @@ Represents EAP configuration information.
| caCertAliases | string | Yes| No| CA certificate alias.| | caCertAliases | string | Yes| No| CA certificate alias.|
| caPath | string | Yes| No| CA certificate path.| | caPath | string | Yes| No| CA certificate path.|
| clientCertAliases | string | Yes| No| Client certificate alias.| | clientCertAliases | string | Yes| No| Client certificate alias.|
| certEntry | Uint8Array | Yes| Yes| CA certificate content.|
| certPassword | string | Yes| Yes| CA certificate password.|
| altSubjectMatch | string | Yes| No| A string to match the alternate subject.| | altSubjectMatch | string | Yes| No| A string to match the alternate subject.|
| domainSuffixMatch | string | Yes| No| A string to match the domain suffix.| | domainSuffixMatch | string | Yes| No| A string to match the domain suffix.|
| realm | string | Yes| No| Realm for the passpoint credential.| | realm | string | Yes| No| Realm for the passpoint credential.|
...@@ -418,6 +478,13 @@ Adds network configuration. This API uses an asynchronous callback to return the ...@@ -418,6 +478,13 @@ Adds network configuration. This API uses an asynchronous callback to return the
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.| | config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the network configuration ID. If **data** is **-1**, the operation has failed. If **err** is not **0**, an error has occurred.| | callback | AsyncCallback&lt;number&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the network configuration ID. If **data** is **-1**, the operation has failed. If **err** is not **0**, an error has occurred.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.addCandidateConfig<sup>9+</sup> ## wifi.addCandidateConfig<sup>9+</sup>
...@@ -441,6 +508,13 @@ Adds the configuration of a candidate network. This API uses a promise to return ...@@ -441,6 +508,13 @@ Adds the configuration of a candidate network. This API uses a promise to return
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the network configuration ID.| | Promise&lt;number&gt; | Promise used to return the network configuration ID.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.addCandidateConfig<sup>9+</sup> ## wifi.addCandidateConfig<sup>9+</sup>
...@@ -459,6 +533,13 @@ Adds the configuration of a candidate network. This API uses an asynchronous cal ...@@ -459,6 +533,13 @@ Adds the configuration of a candidate network. This API uses an asynchronous cal
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.| | config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the network configuration ID. If **data** is **-1**, the operation has failed. If **err** is not **0**, an error has occurred.| | callback | AsyncCallback&lt;number&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the network configuration ID. If **data** is **-1**, the operation has failed. If **err** is not **0**, an error has occurred.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.removeCandidateConfig<sup>9+</sup> ## wifi.removeCandidateConfig<sup>9+</sup>
...@@ -482,6 +563,13 @@ Removes the configuration of a candidate network. This API uses a promise to ret ...@@ -482,6 +563,13 @@ Removes the configuration of a candidate network. This API uses a promise to ret
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.removeCandidateConfig<sup>9+</sup> ## wifi.removeCandidateConfig<sup>9+</sup>
...@@ -500,6 +588,13 @@ Removes the configuration of a candidate network. This API uses an asynchronous ...@@ -500,6 +588,13 @@ Removes the configuration of a candidate network. This API uses an asynchronous
| networkId | number | Yes| ID of the network configuration to remove.| | networkId | number | Yes| ID of the network configuration to remove.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the result. If the operation is successful, the value of **err** is **0**. If **err** is not **0**, an error has occurred.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the result. If the operation is successful, the value of **err** is **0**. If **err** is not **0**, an error has occurred.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.getCandidateConfigs<sup>9+</sup> ## wifi.getCandidateConfigs<sup>9+</sup>
...@@ -517,6 +612,13 @@ Obtains candidate network configuration. ...@@ -517,6 +612,13 @@ Obtains candidate network configuration.
| -------- | -------- | | -------- | -------- |
| &nbsp;Array&lt;[WifiDeviceConfig](#wifideviceconfig)&gt; | Candidate network configuration obtained.| | &nbsp;Array&lt;[WifiDeviceConfig](#wifideviceconfig)&gt; | Candidate network configuration obtained.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.connectToCandidateConfig<sup>9+</sup> ## wifi.connectToCandidateConfig<sup>9+</sup>
...@@ -534,6 +636,14 @@ Connects to a candidate network. ...@@ -534,6 +636,14 @@ Connects to a candidate network.
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| networkId | number | Yes| ID of the candidate network configuration.| | networkId | number | Yes| ID of the candidate network configuration.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501001 | Wifi is closed.|
## wifi.connectToNetwork<sup>9+</sup> ## wifi.connectToNetwork<sup>9+</sup>
...@@ -553,12 +663,14 @@ Connects to the specified network. ...@@ -553,12 +663,14 @@ Connects to the specified network.
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| networkId | number | Yes| Network configuration ID.| | networkId | number | Yes| Network configuration ID.|
**Return value** **Error codes**
| **Type**| **Description**| For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501001 | Wifi is closed.|
## wifi.connectToDevice<sup>9+</sup> ## wifi.connectToDevice<sup>9+</sup>
...@@ -579,12 +691,14 @@ Connects to the specified network. ...@@ -579,12 +691,14 @@ Connects to the specified network.
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration.| | config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration.|
**Return value** **Error codes**
| **Type**| **Description**| For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501001 | Wifi is closed.|
## wifi.disconnect<sup>9+</sup> ## wifi.disconnect<sup>9+</sup>
...@@ -599,12 +713,13 @@ Disconnects the network. ...@@ -599,12 +713,13 @@ Disconnects the network.
**System capability**: **System capability**:
SystemCapability.Communication.WiFi.STA SystemCapability.Communication.WiFi.STA
**Return value** **Error codes**
| **Type**| **Description**| For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.getSignalLevel<sup>9+</sup> ## wifi.getSignalLevel<sup>9+</sup>
...@@ -629,6 +744,13 @@ Obtains the WLAN signal level. ...@@ -629,6 +744,13 @@ Obtains the WLAN signal level.
| -------- | -------- | | -------- | -------- |
| number | Signal level obtained. The value range is [0, 4].| | number | Signal level obtained. The value range is [0, 4].|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.getLinkedInfo<sup>9+</sup> ## wifi.getLinkedInfo<sup>9+</sup>
...@@ -646,6 +768,14 @@ Obtains WLAN connection information. This API uses a promise to return the resul ...@@ -646,6 +768,14 @@ Obtains WLAN connection information. This API uses a promise to return the resul
| -------- | -------- | | -------- | -------- |
| Promise&lt;[WifiLinkedInfo](#wifilinkedinfo)&gt; | Promise used to return the WLAN connection information obtained.| | Promise&lt;[WifiLinkedInfo](#wifilinkedinfo)&gt; | Promise used to return the WLAN connection information obtained.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501001 | Wifi is closed.|
## wifi.getLinkedInfo<sup>9+</sup> ## wifi.getLinkedInfo<sup>9+</sup>
...@@ -663,6 +793,15 @@ Obtains WLAN connection information. This API uses an asynchronous callback to r ...@@ -663,6 +793,15 @@ Obtains WLAN connection information. This API uses an asynchronous callback to r
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[WifiLinkedInfo](#wifilinkedinfo)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the WLAN connection information obtained. If **err** is not **0**, an error has occurred.| | callback | AsyncCallback&lt;[WifiLinkedInfo](#wifilinkedinfo)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the WLAN connection information obtained. If **err** is not **0**, an error has occurred.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501001 | Wifi is closed.|
**Example** **Example**
```js ```js
import wifi from '@ohos.wifi'; import wifi from '@ohos.wifi';
...@@ -767,6 +906,13 @@ Checks whether the WLAN is connected. ...@@ -767,6 +906,13 @@ Checks whether the WLAN is connected.
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the WLAN is connected; returns **false** otherwise.| | boolean | Returns **true** if the WLAN is connected; returns **false** otherwise.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.getSupportedFeatures<sup>9+</sup> ## wifi.getSupportedFeatures<sup>9+</sup>
...@@ -795,12 +941,19 @@ Obtains the features supported by this device. ...@@ -795,12 +941,19 @@ Obtains the features supported by this device.
| 0x0004 | Generic Advertisement Service (GAS)/Access Network Query Protocol (ANQP) feature| | 0x0004 | Generic Advertisement Service (GAS)/Access Network Query Protocol (ANQP) feature|
| 0x0008 | Wi-Fi Direct| | 0x0008 | Wi-Fi Direct|
| 0x0010 | SoftAP| | 0x0010 | SoftAP|
| 0x0040 | Wi-Fi AWare| | 0x0040 | Wi-Fi Aware|
| 0x8000 | WLAN AP/STA concurrency| | 0x8000 | WLAN AP/STA concurrency|
| 0x8000000 | WPA3 Personal (WPA-3 SAE)| | 0x8000000 | WPA3 Personal (WPA-3 SAE)|
| 0x10000000 | WPA3-Enterprise Suite B | | 0x10000000 | WPA3-Enterprise Suite B |
| 0x20000000 | Enhanced open feature| | 0x20000000 | Enhanced open feature|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2401000 | Operation failed.|
## wifi.isFeatureSupported<sup>9+</sup> ## wifi.isFeatureSupported<sup>9+</sup>
...@@ -825,6 +978,13 @@ Checks whether the device supports the specified WLAN feature. ...@@ -825,6 +978,13 @@ Checks whether the device supports the specified WLAN feature.
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the feature is supported; returns **false** otherwise.| | boolean | Returns **true** if the feature is supported; returns **false** otherwise.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2401000 | Operation failed.|
## wifi.getDeviceMacAddress<sup>9+</sup> ## wifi.getDeviceMacAddress<sup>9+</sup>
...@@ -844,6 +1004,13 @@ Obtains the device MAC address. ...@@ -844,6 +1004,13 @@ Obtains the device MAC address.
| -------- | -------- | | -------- | -------- |
| string[] | MAC address obtained.| | string[] | MAC address obtained.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.getIpInfo<sup>9+</sup> ## wifi.getIpInfo<sup>9+</sup>
...@@ -861,6 +1028,13 @@ Obtains IP information. ...@@ -861,6 +1028,13 @@ Obtains IP information.
| -------- | -------- | | -------- | -------- |
| [IpInfo](#ipinfo9) | IP information obtained.| | [IpInfo](#ipinfo9) | IP information obtained.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## IpInfo<sup>9+</sup> ## IpInfo<sup>9+</sup>
...@@ -895,6 +1069,13 @@ Obtains the country code. ...@@ -895,6 +1069,13 @@ Obtains the country code.
| -------- | -------- | | -------- | -------- |
| string | Country code obtained.| | string | Country code obtained.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2401000 | Operation failed.|
## wifi.reassociate<sup>9+</sup> ## wifi.reassociate<sup>9+</sup>
...@@ -908,12 +1089,14 @@ Re-associates with the network. ...@@ -908,12 +1089,14 @@ Re-associates with the network.
**System capability**: SystemCapability.Communication.WiFi.STA **System capability**: SystemCapability.Communication.WiFi.STA
**Return value** **Error codes**
| **Type**| **Description**| For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501001 | Wifi is closed.|
## wifi.reconnect<sup>9+</sup> ## wifi.reconnect<sup>9+</sup>
...@@ -927,12 +1110,14 @@ Reconnects to the network. ...@@ -927,12 +1110,14 @@ Reconnects to the network.
**System capability**: SystemCapability.Communication.WiFi.STA **System capability**: SystemCapability.Communication.WiFi.STA
**Return value** **Error codes**
| **Type**| **Description**| For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501001 | Wifi is closed.|
## wifi.getDeviceConfigs<sup>9+</sup> ## wifi.getDeviceConfigs<sup>9+</sup>
...@@ -952,6 +1137,13 @@ Obtains network configuration. ...@@ -952,6 +1137,13 @@ Obtains network configuration.
| -------- | -------- | | -------- | -------- |
| &nbsp;Array&lt;[WifiDeviceConfig](#wifideviceconfig)&gt; | Array of network configuration obtained.| | &nbsp;Array&lt;[WifiDeviceConfig](#wifideviceconfig)&gt; | Array of network configuration obtained.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.updateNetwork<sup>9+</sup> ## wifi.updateNetwork<sup>9+</sup>
...@@ -977,6 +1169,13 @@ Updates network configuration. ...@@ -977,6 +1169,13 @@ Updates network configuration.
| -------- | -------- | | -------- | -------- |
| number | ID of the updated network configuration. The value **-1** indicates that the operation has failed.| | number | ID of the updated network configuration. The value **-1** indicates that the operation has failed.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.disableNetwork<sup>9+</sup> ## wifi.disableNetwork<sup>9+</sup>
...@@ -996,12 +1195,13 @@ Disables network configuration. ...@@ -996,12 +1195,13 @@ Disables network configuration.
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| netId | number | Yes| ID of the network configuration to disable.| | netId | number | Yes| ID of the network configuration to disable.|
**Return value** **Error codes**
| **Type**| **Description**| For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.removeAllNetwork<sup>9+</sup> ## wifi.removeAllNetwork<sup>9+</sup>
...@@ -1015,12 +1215,13 @@ Removes the configuration of all networks. ...@@ -1015,12 +1215,13 @@ Removes the configuration of all networks.
**System capability**: SystemCapability.Communication.WiFi.STA **System capability**: SystemCapability.Communication.WiFi.STA
**Return value** **Error codes**
| **Type**| **Description**| For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.removeDevice<sup>9+</sup> ## wifi.removeDevice<sup>9+</sup>
...@@ -1038,14 +1239,15 @@ Removes the specified network configuration. ...@@ -1038,14 +1239,15 @@ Removes the specified network configuration.
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| id | number | Yes| ID of the network configuration to remove.| | id | number | Yes| ID of the network configuration to remove.|
**Return value** **Error codes**
| **Type**| **Description**| For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.enableHotspot<sup>9+</sup> ## wifi.enableHotspot<sup>9+</sup>
...@@ -1059,12 +1261,13 @@ Enables this hotspot. ...@@ -1059,12 +1261,13 @@ Enables this hotspot.
**System capability**: SystemCapability.Communication.WiFi.AP.Core **System capability**: SystemCapability.Communication.WiFi.AP.Core
**Return value** **Error codes**
| **Type**| **Description**| For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| 2601000 | Operation failed.|
## wifi.disableHotspot<sup>9+</sup> ## wifi.disableHotspot<sup>9+</sup>
...@@ -1078,12 +1281,13 @@ Disables this hotspot. ...@@ -1078,12 +1281,13 @@ Disables this hotspot.
**System capability**: SystemCapability.Communication.WiFi.AP.Core **System capability**: SystemCapability.Communication.WiFi.AP.Core
**Return value** **Error codes**
| **Type**| **Description**| For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| 2601000 | Operation failed.|
## wifi.isHotspotDualBandSupported<sup>9+</sup> ## wifi.isHotspotDualBandSupported<sup>9+</sup>
...@@ -1103,6 +1307,13 @@ Checks whether the hotspot supports dual band. ...@@ -1103,6 +1307,13 @@ Checks whether the hotspot supports dual band.
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the feature is supported; returns **false** otherwise.| | boolean | Returns **true** if the feature is supported; returns **false** otherwise.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2601000 | Operation failed.|
## wifi.isHotspotActive<sup>9+</sup> ## wifi.isHotspotActive<sup>9+</sup>
...@@ -1122,6 +1333,13 @@ Checks whether this hotspot is active. ...@@ -1122,6 +1333,13 @@ Checks whether this hotspot is active.
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the hotspot is active; returns **false** otherwise.| | boolean | Returns **true** if the hotspot is active; returns **false** otherwise.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2601000 | Operation failed.|
## wifi.setHotspotConfig<sup>9+</sup> ## wifi.setHotspotConfig<sup>9+</sup>
...@@ -1141,12 +1359,13 @@ Sets hotspot configuration. ...@@ -1141,12 +1359,13 @@ Sets hotspot configuration.
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| config | [HotspotConfig](#hotspotconfig9) | Yes| Hotspot configuration to set.| | config | [HotspotConfig](#hotspotconfig9) | Yes| Hotspot configuration to set.|
**Return value** **Error codes**
| **Type**| **Description**| For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| 2601000 | Operation failed.|
## HotspotConfig<sup>9+</sup> ## HotspotConfig<sup>9+</sup>
...@@ -1169,7 +1388,7 @@ Represents the hotspot configuration. ...@@ -1169,7 +1388,7 @@ Represents the hotspot configuration.
getHotspotConfig(): HotspotConfig getHotspotConfig(): HotspotConfig
obtains hotspot configuration. Obtains hotspot configuration.
**System API**: This is a system API. **System API**: This is a system API.
...@@ -1183,6 +1402,13 @@ obtains hotspot configuration. ...@@ -1183,6 +1402,13 @@ obtains hotspot configuration.
| -------- | -------- | | -------- | -------- |
| [HotspotConfig](#hotspotconfig9) | Hotspot configuration obtained.| | [HotspotConfig](#hotspotconfig9) | Hotspot configuration obtained.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2601000 | Operation failed.|
## wifi.getStations<sup>9+</sup> ## wifi.getStations<sup>9+</sup>
...@@ -1202,6 +1428,13 @@ Obtains information about the connected stations. ...@@ -1202,6 +1428,13 @@ Obtains information about the connected stations.
| -------- | -------- | | -------- | -------- |
| &nbsp;Array&lt;[StationInfo](#stationinfo9)&gt; | Connected stations obtained.| | &nbsp;Array&lt;[StationInfo](#stationinfo9)&gt; | Connected stations obtained.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2601000 | Operation failed.|
## StationInfo<sup>9+</sup> ## StationInfo<sup>9+</sup>
...@@ -1234,7 +1467,13 @@ Obtains P2P link information. This API uses a promise to return the result. ...@@ -1234,7 +1467,13 @@ Obtains P2P link information. This API uses a promise to return the result.
| -------- | -------- | | -------- | -------- |
| Promise&lt;[WifiP2pLinkedInfo](#wifip2plinkedinfo9)&gt; | Promise used to return the P2P link information obtained.| | Promise&lt;[WifiP2pLinkedInfo](#wifip2plinkedinfo9)&gt; | Promise used to return the P2P link information obtained.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## WifiP2pLinkedInfo<sup>9+</sup> ## WifiP2pLinkedInfo<sup>9+</sup>
...@@ -1294,6 +1533,13 @@ Obtains the current P2P group information. This API uses a promise to return the ...@@ -1294,6 +1533,13 @@ Obtains the current P2P group information. This API uses a promise to return the
| -------- | -------- | | -------- | -------- |
| Promise&lt;[WifiP2pGroupInfo](#wifip2pgroupinfo9)&gt; | Promise used to return the P2P group information obtained.| | Promise&lt;[WifiP2pGroupInfo](#wifip2pgroupinfo9)&gt; | Promise used to return the P2P group information obtained.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.getCurrentGroup<sup>9+</sup> ## wifi.getCurrentGroup<sup>9+</sup>
...@@ -1311,6 +1557,13 @@ Obtains the current P2P group information. This API uses an asynchronous callbac ...@@ -1311,6 +1557,13 @@ Obtains the current P2P group information. This API uses an asynchronous callbac
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[WifiP2pGroupInfo](#wifip2pgroupinfo9)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the group information obtained. If **err** is not **0**, an error has occurred.| | callback | AsyncCallback&lt;[WifiP2pGroupInfo](#wifip2pgroupinfo9)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the group information obtained. If **err** is not **0**, an error has occurred.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.getP2pPeerDevices<sup>9+</sup> ## wifi.getP2pPeerDevices<sup>9+</sup>
...@@ -1328,6 +1581,13 @@ Obtains the peer device list in the P2P connection. This API uses a promise to r ...@@ -1328,6 +1581,13 @@ Obtains the peer device list in the P2P connection. This API uses a promise to r
| -------- | -------- | | -------- | -------- |
| Promise&lt;[WifiP2pDevice[]](#wifip2pdevice9)&gt; | Promise used to return the peer device list.| | Promise&lt;[WifiP2pDevice[]](#wifip2pdevice9)&gt; | Promise used to return the peer device list.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.getP2pPeerDevices<sup>9+</sup> ## wifi.getP2pPeerDevices<sup>9+</sup>
...@@ -1345,6 +1605,13 @@ Obtains the peer device list in the P2P connection. This API uses an asynchronou ...@@ -1345,6 +1605,13 @@ Obtains the peer device list in the P2P connection. This API uses an asynchronou
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[WifiP2pDevice[]](#wifip2pdevice9)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the peer device list obtained. If **err** is not **0**, an error has occurred.| | callback | AsyncCallback&lt;[WifiP2pDevice[]](#wifip2pdevice9)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the peer device list obtained. If **err** is not **0**, an error has occurred.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## WifiP2pDevice<sup>9+</sup> ## WifiP2pDevice<sup>9+</sup>
...@@ -1392,6 +1659,13 @@ Obtains the local device information in the P2P connection. This API uses a prom ...@@ -1392,6 +1659,13 @@ Obtains the local device information in the P2P connection. This API uses a prom
| -------- | -------- | | -------- | -------- |
| Promise&lt;[WifiP2pDevice](#wifip2pdevice9)&gt; | Promise used to return the local device information obtained.| | Promise&lt;[WifiP2pDevice](#wifip2pdevice9)&gt; | Promise used to return the local device information obtained.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.getP2pLocalDevice<sup>9+</sup> ## wifi.getP2pLocalDevice<sup>9+</sup>
...@@ -1426,12 +1700,13 @@ Creates a P2P group. ...@@ -1426,12 +1700,13 @@ Creates a P2P group.
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| config | [WifiP2PConfig](#wifip2pconfig9) | Yes| Group configuration.| | config | [WifiP2PConfig](#wifip2pconfig9) | Yes| Group configuration.|
**Return value** **Error codes**
| Type| Description| For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## WifiP2PConfig<sup>9+</sup> ## WifiP2PConfig<sup>9+</sup>
...@@ -1471,12 +1746,13 @@ Removes this P2P group. ...@@ -1471,12 +1746,13 @@ Removes this P2P group.
**System capability**: SystemCapability.Communication.WiFi.P2P **System capability**: SystemCapability.Communication.WiFi.P2P
**Return value** **Error codes**
| Type| Description| For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.p2pConnect<sup>9+</sup> ## wifi.p2pConnect<sup>9+</sup>
...@@ -1495,12 +1771,13 @@ Sets up a P2P connection. ...@@ -1495,12 +1771,13 @@ Sets up a P2P connection.
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| config | [WifiP2PConfig](#wifip2pconfig9) | Yes| P2P group configuration.| | config | [WifiP2PConfig](#wifip2pconfig9) | Yes| P2P group configuration.|
**Return value** **Error codes**
| Type| Description| For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
**Example** **Example**
```js ```js
...@@ -1579,12 +1856,13 @@ Cancels this P2P connection. ...@@ -1579,12 +1856,13 @@ Cancels this P2P connection.
**System capability**: SystemCapability.Communication.WiFi.P2P **System capability**: SystemCapability.Communication.WiFi.P2P
**Return value** **Error codes**
| Type| Description| For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.startDiscoverDevices<sup>9+</sup> ## wifi.startDiscoverDevices<sup>9+</sup>
...@@ -1596,12 +1874,13 @@ Starts to discover devices. ...@@ -1596,12 +1874,13 @@ Starts to discover devices.
**System capability**: SystemCapability.Communication.WiFi.P2P **System capability**: SystemCapability.Communication.WiFi.P2P
**Return value** **Error codes**
| Type| Description| For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.stopDiscoverDevices<sup>9+</sup> ## wifi.stopDiscoverDevices<sup>9+</sup>
...@@ -1613,12 +1892,13 @@ Stops discovering devices. ...@@ -1613,12 +1892,13 @@ Stops discovering devices.
**System capability**: SystemCapability.Communication.WiFi.P2P **System capability**: SystemCapability.Communication.WiFi.P2P
**Return value** **Error codes**
| Type| Description| For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.deletePersistentGroup<sup>9+</sup> ## wifi.deletePersistentGroup<sup>9+</sup>
...@@ -1639,12 +1919,13 @@ Deletes a persistent group. ...@@ -1639,12 +1919,13 @@ Deletes a persistent group.
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| netId | number | Yes| ID of the group to delete.| | netId | number | Yes| ID of the group to delete.|
**Return value** **Error codes**
| Type| Description| For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.getP2pGroups<sup>9+</sup> ## wifi.getP2pGroups<sup>9+</sup>
...@@ -1664,6 +1945,13 @@ Obtains information about all P2P groups. This API uses a promise to return the ...@@ -1664,6 +1945,13 @@ Obtains information about all P2P groups. This API uses a promise to return the
| -------- | -------- | | -------- | -------- |
| Promise&lt;&nbsp;Array&lt;[WifiP2pGroupInfo](#wifip2pgroupinfo9)&gt;&nbsp;&gt; | Promise used to return the group information obtained.| | Promise&lt;&nbsp;Array&lt;[WifiP2pGroupInfo](#wifip2pgroupinfo9)&gt;&nbsp;&gt; | Promise used to return the group information obtained.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## WifiP2pGroupInfo<sup>9+</sup> ## WifiP2pGroupInfo<sup>9+</sup>
...@@ -1702,6 +1990,13 @@ Obtains information about all P2P groups. This API uses an asynchronous callback ...@@ -1702,6 +1990,13 @@ Obtains information about all P2P groups. This API uses an asynchronous callback
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;&nbsp;Array&lt;[WifiP2pGroupInfo](#wifip2pgroupinfo9)&gt;&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the group information obtained. If **err** is not **0**, an error has occurred.| | callback | AsyncCallback&lt;&nbsp;Array&lt;[WifiP2pGroupInfo](#wifip2pgroupinfo9)&gt;&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the group information obtained. If **err** is not **0**, an error has occurred.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.setDeviceName<sup>9+</sup> ## wifi.setDeviceName<sup>9+</sup>
...@@ -1721,12 +2016,13 @@ Sets the device name. ...@@ -1721,12 +2016,13 @@ Sets the device name.
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| devName | string | Yes| Device name to set.| | devName | string | Yes| Device name to set.|
**Return value** **Error codes**
| **Type**| **Description**| For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.on('wifiStateChange')<sup>9+</sup> ## wifi.on('wifiStateChange')<sup>9+</sup>
...@@ -1745,6 +2041,14 @@ Registers the WLAN state change events. ...@@ -1745,6 +2041,14 @@ Registers the WLAN state change events.
| type | string | Yes| Event type. The value is **wifiStateChange**.| | type | string | Yes| Event type. The value is **wifiStateChange**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the WLAN state.| | callback | Callback&lt;number&gt; | Yes| Callback invoked to return the WLAN state.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
**WLAN states** **WLAN states**
| **Value**| **Description**| | **Value**| **Description**|
...@@ -1772,6 +2076,14 @@ Unregisters the WLAN state change events. ...@@ -1772,6 +2076,14 @@ Unregisters the WLAN state change events.
| type | string | Yes| Event type. The value is **wifiStateChange**.| | type | string | Yes| Event type. The value is **wifiStateChange**.|
| callback | Callback&lt;number&gt; | No| Callback for the WLAN state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| | callback | Callback&lt;number&gt; | No| Callback for the WLAN state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
**Example** **Example**
```js ```js
import wifi from '@ohos.wifi'; import wifi from '@ohos.wifi';
...@@ -1788,7 +2100,7 @@ Unregisters the WLAN state change events. ...@@ -1788,7 +2100,7 @@ Unregisters the WLAN state change events.
``` ```
## wifi.on('wifiConnectionChange')<sup>7+</sup> ## wifi.on('wifiConnectionChange')<sup>9+</sup>
on(type: "wifiConnectionChange", callback: Callback&lt;number&gt;): void on(type: "wifiConnectionChange", callback: Callback&lt;number&gt;): void
...@@ -1812,6 +2124,13 @@ Registers the WLAN connection state change events. ...@@ -1812,6 +2124,13 @@ Registers the WLAN connection state change events.
| 0 | Disconnected.| | 0 | Disconnected.|
| 1 | Connected.| | 1 | Connected.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.off('wifiConnectionChange')<sup>9+</sup> ## wifi.off('wifiConnectionChange')<sup>9+</sup>
...@@ -1830,6 +2149,13 @@ Unregisters the WLAN connection state change events. ...@@ -1830,6 +2149,13 @@ Unregisters the WLAN connection state change events.
| type | string | Yes| Event type. The value is **wifiConnectionChange**.| | type | string | Yes| Event type. The value is **wifiConnectionChange**.|
| callback | Callback&lt;number&gt; | No| Callback for the WLAN connection state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| | callback | Callback&lt;number&gt; | No| Callback for the WLAN connection state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.on('wifiScanStateChange')<sup>9+</sup> ## wifi.on('wifiScanStateChange')<sup>9+</sup>
...@@ -1855,6 +2181,13 @@ Registers the WLAN scan state change events. ...@@ -1855,6 +2181,13 @@ Registers the WLAN scan state change events.
| 0 | Scan failed.| | 0 | Scan failed.|
| 1 | Scan successful.| | 1 | Scan successful.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.off('wifiScanStateChange')<sup>9+</sup> ## wifi.off('wifiScanStateChange')<sup>9+</sup>
...@@ -1873,6 +2206,13 @@ Unregisters the WLAN scan state change events. ...@@ -1873,6 +2206,13 @@ Unregisters the WLAN scan state change events.
| type | string | Yes| Event type. The value is **wifiScanStateChange**.| | type | string | Yes| Event type. The value is **wifiScanStateChange**.|
| callback | Callback&lt;number&gt; | No| Callback for the WLAN scan state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| | callback | Callback&lt;number&gt; | No| Callback for the WLAN scan state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.on('wifiRssiChange')<sup>9+</sup> ## wifi.on('wifiRssiChange')<sup>9+</sup>
...@@ -1891,6 +2231,13 @@ Registers the RSSI change events. ...@@ -1891,6 +2231,13 @@ Registers the RSSI change events.
| type | string | Yes| Event type. The value is **wifiRssiChange**.| | type | string | Yes| Event type. The value is **wifiRssiChange**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the RSSI, in dBm.| | callback | Callback&lt;number&gt; | Yes| Callback invoked to return the RSSI, in dBm.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.off('wifiRssiChange')<sup>9+</sup> ## wifi.off('wifiRssiChange')<sup>9+</sup>
...@@ -1909,6 +2256,13 @@ Unregisters the RSSI change events. ...@@ -1909,6 +2256,13 @@ Unregisters the RSSI change events.
| type | string | Yes| Event type. The value is **wifiRssiChange**.| | type | string | Yes| Event type. The value is **wifiRssiChange**.|
| callback | Callback&lt;number&gt; | No| Callback for the RSSI. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| | callback | Callback&lt;number&gt; | No| Callback for the RSSI. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.on('hotspotStateChange')<sup>9+</sup> ## wifi.on('hotspotStateChange')<sup>9+</sup>
...@@ -1936,6 +2290,13 @@ Registers the hotspot state change events. ...@@ -1936,6 +2290,13 @@ Registers the hotspot state change events.
| 2 | Activating| | 2 | Activating|
| 3 | Deactivating| | 3 | Deactivating|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2601000 | Operation failed.|
## wifi.off('hotspotStateChange')<sup>9+</sup> ## wifi.off('hotspotStateChange')<sup>9+</sup>
...@@ -1954,6 +2315,13 @@ Unregisters the hotspot state change events. ...@@ -1954,6 +2315,13 @@ Unregisters the hotspot state change events.
| type | string | Yes| Event type. The value is **hotspotStateChange**.| | type | string | Yes| Event type. The value is **hotspotStateChange**.|
| callback | Callback&lt;number&gt; | No| Callback for the hotspot state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| | callback | Callback&lt;number&gt; | No| Callback for the hotspot state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2601000 | Operation failed.|
## wifi.on('p2pStateChange')<sup>9+</sup> ## wifi.on('p2pStateChange')<sup>9+</sup>
...@@ -1982,6 +2350,14 @@ Registers the P2P state change events. ...@@ -1982,6 +2350,14 @@ Registers the P2P state change events.
| 4 | Closing| | 4 | Closing|
| 5 | Closed| | 5 | Closed|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.off('p2pStateChange')<sup>9+</sup> ## wifi.off('p2pStateChange')<sup>9+</sup>
off(type: "p2pStateChange", callback?: Callback&lt;number&gt;): void off(type: "p2pStateChange", callback?: Callback&lt;number&gt;): void
...@@ -1999,6 +2375,13 @@ Unregisters the P2P state change events. ...@@ -1999,6 +2375,13 @@ Unregisters the P2P state change events.
| type | string | Yes| Event type. The value is **p2pStateChange**.| | type | string | Yes| Event type. The value is **p2pStateChange**.|
| callback | Callback&lt;number&gt; | No| Callback for the P2P state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| | callback | Callback&lt;number&gt; | No| Callback for the P2P state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.on('p2pConnectionChange')<sup>9+</sup> ## wifi.on('p2pConnectionChange')<sup>9+</sup>
...@@ -2017,6 +2400,13 @@ Registers the P2P connection state change events. ...@@ -2017,6 +2400,13 @@ Registers the P2P connection state change events.
| type | string | Yes| Event type. The value is **p2pConnectionChange**.| | type | string | Yes| Event type. The value is **p2pConnectionChange**.|
| callback | Callback&lt;[WifiP2pLinkedInfo](#wifip2plinkedinfo9)&gt; | Yes| Callback invoked to return the P2P connection state.| | callback | Callback&lt;[WifiP2pLinkedInfo](#wifip2plinkedinfo9)&gt; | Yes| Callback invoked to return the P2P connection state.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.off('p2pConnectionChange')<sup>9+</sup> ## wifi.off('p2pConnectionChange')<sup>9+</sup>
...@@ -2035,6 +2425,13 @@ Unregisters the P2P connection state change events. ...@@ -2035,6 +2425,13 @@ Unregisters the P2P connection state change events.
| type | string | Yes| Event type. The value is **p2pConnectionChange**.| | type | string | Yes| Event type. The value is **p2pConnectionChange**.|
| callback | Callback&lt;[WifiP2pLinkedInfo](#wifip2plinkedinfo9)&gt; | No| Callback for the P2P connection state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| | callback | Callback&lt;[WifiP2pLinkedInfo](#wifip2plinkedinfo9)&gt; | No| Callback for the P2P connection state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.on('p2pDeviceChange')<sup>9+</sup> ## wifi.on('p2pDeviceChange')<sup>9+</sup>
...@@ -2053,6 +2450,13 @@ Registers the P2P device state change events. ...@@ -2053,6 +2450,13 @@ Registers the P2P device state change events.
| type | string | Yes| Event type. The value is **p2pDeviceChange**.| | type | string | Yes| Event type. The value is **p2pDeviceChange**.|
| callback | Callback&lt;[WifiP2pDevice](#wifip2pdevice9)&gt; | Yes| Callback invoked to return the P2P device state.| | callback | Callback&lt;[WifiP2pDevice](#wifip2pdevice9)&gt; | Yes| Callback invoked to return the P2P device state.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.off('p2pDeviceChange')<sup>9+</sup> ## wifi.off('p2pDeviceChange')<sup>9+</sup>
...@@ -2071,6 +2475,13 @@ Unregisters the P2P device state change events. ...@@ -2071,6 +2475,13 @@ Unregisters the P2P device state change events.
| type | string | Yes| Event type. The value is **p2pDeviceChange**.| | type | string | Yes| Event type. The value is **p2pDeviceChange**.|
| callback | Callback&lt;[WifiP2pDevice](#wifip2pdevice9)&gt; | No| Callback for the P2P device state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| | callback | Callback&lt;[WifiP2pDevice](#wifip2pdevice9)&gt; | No| Callback for the P2P device state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.on('p2pPeerDeviceChange')<sup>9+</sup> ## wifi.on('p2pPeerDeviceChange')<sup>9+</sup>
...@@ -2089,6 +2500,13 @@ Registers the P2P peer device state change events. ...@@ -2089,6 +2500,13 @@ Registers the P2P peer device state change events.
| type | string | Yes| Event type. The value is **p2pPeerDeviceChange**.| | type | string | Yes| Event type. The value is **p2pPeerDeviceChange**.|
| callback | Callback&lt;[WifiP2pDevice[]](#wifip2pdevice9)&gt; | Yes| Callback invoked to return the P2P peer device state.| | callback | Callback&lt;[WifiP2pDevice[]](#wifip2pdevice9)&gt; | Yes| Callback invoked to return the P2P peer device state.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.off('p2pPeerDeviceChange')<sup>9+</sup> ## wifi.off('p2pPeerDeviceChange')<sup>9+</sup>
...@@ -2107,6 +2525,13 @@ Unregisters the P2P peer device state change events. ...@@ -2107,6 +2525,13 @@ Unregisters the P2P peer device state change events.
| type | string | Yes| Event type. The value is **p2pPeerDeviceChange**.| | type | string | Yes| Event type. The value is **p2pPeerDeviceChange**.|
| callback | Callback&lt;[WifiP2pDevice[]](#wifip2pdevice9)&gt; | No| Callback for the peer device state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| | callback | Callback&lt;[WifiP2pDevice[]](#wifip2pdevice9)&gt; | No| Callback for the peer device state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.on('p2pPersistentGroupChange')<sup>9+</sup> ## wifi.on('p2pPersistentGroupChange')<sup>9+</sup>
...@@ -2125,6 +2550,13 @@ Registers the P2P persistent group state change events. ...@@ -2125,6 +2550,13 @@ Registers the P2P persistent group state change events.
| type | string | Yes| Event type. The value is **p2pPersistentGroupChange**.| | type | string | Yes| Event type. The value is **p2pPersistentGroupChange**.|
| callback | Callback&lt;void&gt; | Yes| Callback invoked to return the P2P persistent group state.| | callback | Callback&lt;void&gt; | Yes| Callback invoked to return the P2P persistent group state.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.off('p2pPersistentGroupChange')<sup>9+</sup> ## wifi.off('p2pPersistentGroupChange')<sup>9+</sup>
...@@ -2143,6 +2575,13 @@ Unregisters the P2P persistent group state change events. ...@@ -2143,6 +2575,13 @@ Unregisters the P2P persistent group state change events.
| type | string | Yes| Event type. The value is **p2pPersistentGroupChange**.| | type | string | Yes| Event type. The value is **p2pPersistentGroupChange**.|
| callback | Callback&lt;void&gt; | No| Callback for the P2P persistent group state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| | callback | Callback&lt;void&gt; | No| Callback for the P2P persistent group state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.on('p2pDiscoveryChange')<sup>9+</sup> ## wifi.on('p2pDiscoveryChange')<sup>9+</sup>
...@@ -2168,6 +2607,13 @@ Registers the P2P device discovery state change events. ...@@ -2168,6 +2607,13 @@ Registers the P2P device discovery state change events.
| 0 | Initial state.| | 0 | Initial state.|
| 1 | Discovered.| | 1 | Discovered.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.off('p2pDiscoveryChange')<sup>9+</sup> ## wifi.off('p2pDiscoveryChange')<sup>9+</sup>
...@@ -2185,3 +2631,11 @@ Unregisters the P2P device discovery state change events. ...@@ -2185,3 +2631,11 @@ Unregisters the P2P device discovery state change events.
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pDiscoveryChange**.| | type | string | Yes| Event type. The value is **p2pDiscoveryChange**.|
| callback | Callback&lt;number&gt; | No| Callback for the P2P device discovery state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| | callback | Callback&lt;number&gt; | No| Callback for the P2P device discovery state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
# WLAN Extension Interface # @ohos.wifiManagerExt (WLAN Extension)
This **wifiext** module provides WLAN extension interfaces for non-universal products. This **wifiext** module provides WLAN extension interfaces for non-universal products.
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API version 8. 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 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The APIs described in this document are used only for non-universal products, such as routers. > - The APIs described in this document are used only for non-universal products, such as routers.
## Modules to Import ## Modules to Import
...@@ -14,9 +14,9 @@ The APIs described in this document are used only for non-universal products, su ...@@ -14,9 +14,9 @@ The APIs described in this document are used only for non-universal products, su
import wifiManagerExt from '@ohos.wifiManagerExt'; import wifiManagerExt from '@ohos.wifiManagerExt';
``` ```
## wifiext.enableHotspot ## wifiext.enableHotspot<sup>9+</sup>
enableHotspot(): boolean; enableHotspot(): void;
Enables the WLAN hotspot. Enables the WLAN hotspot.
...@@ -24,16 +24,17 @@ Enables the WLAN hotspot. ...@@ -24,16 +24,17 @@ Enables the WLAN hotspot.
**System capability**: SystemCapability.Communication.WiFi.AP.Extension **System capability**: SystemCapability.Communication.WiFi.AP.Extension
**Return value** **Error codes**
| **Type**| **Description**| For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| 2701000 | Operation failed.|
## wifiext.disableHotspot ## wifiext.disableHotspot<sup>9+</sup>
disableHotspot(): boolean; disableHotspot(): void;
Disables the WLAN hotspot. Disables the WLAN hotspot.
...@@ -41,18 +42,19 @@ Disables the WLAN hotspot. ...@@ -41,18 +42,19 @@ Disables the WLAN hotspot.
**System capability**: SystemCapability.Communication.WiFi.AP.Extension **System capability**: SystemCapability.Communication.WiFi.AP.Extension
**Return value** **Error codes**
| **Type**| **Description**| For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| 2701000 | Operation failed.|
## wifiext.getSupportedPowerModel ## wifiext.getSupportedPowerMode<sup>9+</sup>
getSupportedPowerModel(): Promise&lt;Array&lt;PowerModel&gt;&gt; getSupportedPowerMode(): Promise&lt;Array&lt;PowerMode&gt;&gt;
Obtains the supported power models. This API uses a promise to return the result. Obtains the supported power modes. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_WIFI_INFO **Required permissions**: ohos.permission.GET_WIFI_INFO
...@@ -60,14 +62,21 @@ Obtains the supported power models. This API uses a promise to return the result ...@@ -60,14 +62,21 @@ Obtains the supported power models. This API uses a promise to return the result
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;Array&lt;[PowerModel](#powermodel)&gt;&gt; | Promise used to return the power models obtained.| | Promise&lt;Array&lt;[PowerMode](#powermode)&gt;&gt; | Promise used to return the power modes obtained.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
## PowerModel | **Type**| **Description**|
| -------- | -------- |
| 2701000 | Operation failed.|
Enumerates the power models. ## PowerMode
Enumerates the power modes.
**System capability**: SystemCapability.Communication.WiFi.AP.Extension **System capability**: SystemCapability.Communication.WiFi.AP.Extension
...@@ -78,11 +87,11 @@ Enumerates the power models. ...@@ -78,11 +87,11 @@ Enumerates the power models.
| THROUGH_WALL | 2 | Through_wall| | THROUGH_WALL | 2 | Through_wall|
## wifiext.getSupportedPowerModel ## wifiext.getSupportedPowerMode<sup>9+</sup>
getSupportedPowerModel(callback: AsyncCallback&lt;Array&lt;PowerModel&gt;&gt;): void getSupportedPowerMode(callback: AsyncCallback&lt;Array&lt;PowerMode&gt;&gt;): void
Obtains the supported power models. This API uses an asynchronous callback to return the result. Obtains the supported power modes. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_WIFI_INFO **Required permissions**: ohos.permission.GET_WIFI_INFO
...@@ -90,16 +99,23 @@ Obtains the supported power models. This API uses an asynchronous callback to re ...@@ -90,16 +99,23 @@ Obtains the supported power models. This API uses an asynchronous callback to re
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;Array&lt;[PowerModel](#powermodel)&gt;&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is 0 and **data** is the power models obtained. If **err** is not **0**, an error has occurred.| | callback | AsyncCallback&lt;Array&lt;[PowerMode](#powermode)&gt;&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power modes obtained. If **err** is not **0**, an error has occurred.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2701000 | Operation failed.|
## wifiext.getPowerModel ## wifiext.getPowerMode<sup>9+</sup>
getPowerModel(): Promise&lt;PowerModel&gt; getPowerMode(): Promise&lt;PowerMode&gt;
Obtains the power model. This API uses a promise to return the result. Obtains the power mode. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_WIFI_INFO **Required permissions**: ohos.permission.GET_WIFI_INFO
...@@ -107,16 +123,23 @@ Obtains the power model. This API uses a promise to return the result. ...@@ -107,16 +123,23 @@ Obtains the power model. This API uses a promise to return the result.
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;[PowerModel](#powermodel)&gt; | Promise used to return the power model obtained.| | Promise&lt;[PowerMode](#powermode)&gt; | Promise used to return the power modes obtained.|
**Error codes**
## wifiext.getPowerModel For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
getPowerModel(callback: AsyncCallback&lt;PowerModel&gt;): void | **Type**| **Description**|
| -------- | -------- |
| 2701000 | Operation failed.|
Obtains the power model. This API uses an asynchronous callback to return the result. ## wifiext.getPowerMode<sup>9+</sup>
getPowerMode(callback: AsyncCallback&lt;PowerMode&gt;): void
Obtains the power mode. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_WIFI_INFO **Required permissions**: ohos.permission.GET_WIFI_INFO
...@@ -124,16 +147,23 @@ Obtains the power model. This API uses an asynchronous callback to return the re ...@@ -124,16 +147,23 @@ Obtains the power model. This API uses an asynchronous callback to return the re
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[PowerModel](#powermodel)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power model obtained. If **err** is not **0**, an error has occurred.| | callback | AsyncCallback&lt;[PowerMode](#powermode)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power mode obtained. If **err** is not **0**, an error has occurred.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
## wifiext.setPowerModel | **Type**| **Description**|
| -------- | -------- |
| 2701000 | Operation failed.|
setPowerModel(model: PowerModel) : boolean; ## wifiext.setPowerMode<sup>9+</sup>
Sets the power model. setPowerMode(model: PowerMode) : boolean;
Sets the power mode.
**Required permissions**: ohos.permission.MANAGE_WIFI_HOTSPOT_EXT **Required permissions**: ohos.permission.MANAGE_WIFI_HOTSPOT_EXT
...@@ -141,12 +171,14 @@ setPowerModel(model: PowerModel) : boolean; ...@@ -141,12 +171,14 @@ setPowerModel(model: PowerModel) : boolean;
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| model | [PowerModel](#powermodel) | Yes| Power model to set.| | model | [PowerMode](#powermode) | Yes| Power mode to set.|
**Return value** **Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | 2701000 | Operation failed.|
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
- [NFC Error Codes](errorcode-nfc.md) - [NFC Error Codes](errorcode-nfc.md)
- [RPC Error Codes](errorcode-rpc.md) - [RPC Error Codes](errorcode-rpc.md)
- [Bluetooth Error Codes](errorcode-bluetoothManager.md) - [Bluetooth Error Codes](errorcode-bluetoothManager.md)
- [Wi-Fi Error Codes](errorcode-wifi.md)
- Basic Features - Basic Features
- [Accessibility Error Codes](errorcode-accessibility.md) - [Accessibility Error Codes](errorcode-accessibility.md)
- [FaultLogger Error Codes](errorcode-faultlogger.md) - [FaultLogger Error Codes](errorcode-faultlogger.md)
......
# Wi-Fi Error Codes
## 2401000 STA Internal Error
**Error Message**
Operation failed.
**Description**
An error occurs when the Wi-Fi service performs an operation related to the station (STA).
**Possible Causes**
1. Communication between the Wi-Fi service and the STA failed.
2. The Wi-Fi chip communication is abnormal.
3. An unknown error has occurred.
**Solution**
1. Disable and then enable the Wi-Fi function again.
2. If the error persists, restart the device.
## 2501000 STA Internal Error
**Error Message**
Operation failed.
**Description**
An error occurs when the Wi-Fi service performs a STA-related operation.
**Possible Causes**
1. Communication between the Wi-Fi service and the STA failed.
2. The Wi-Fi chip communication is abnormal.
3. An unknown error has occurred.
**Solution**
1. Disable and then enable the Wi-Fi function again.
2. If the error persists, restart the device.
## 2501001 STA Disabled
**Error Message**
Wifi is closed.
**Description**
The Wi-Fi STA function is disabled.
**Possible Causes**
The Wi-Fi function is disabled.
**Solution**
Enable the Wi-Fi function.
## 2601000 Hotspot Module Error
**Error Message**
Operation failed.
**Description**
An error occurs when the Wi-Fi service performs a hotspot-related operation.
**Possible Causes**
1. Communication between the Wi-Fi service and the hotspot failed.
2. The Wi-Fi chip communication is abnormal.
3. An unknown error has occurred.
**Solution**
1. Disable and then enable the hotspot again.
2. If the error persists, restart the device.
## 2701000 AP Extension Module Error
**Error Message**
Operation failed.
**Description**
An error occurs when the Wi-Fi service performs a hotspot-related operation.
**Possible Causes**
1. Communication between the Wi-Fi service and the hotspot failed.
2. The Wi-Fi chip communication is abnormal.
3. An unknown error has occurred.
**Solution**
1. Disable and then enable the hotspot again.
2. If the error persists, restart the device.
## 2801000 P2P Module Error
**Error Message**
Operation failed.
**Description**
An error occurs when the Wi-Fi service performs a P2P-related operation.
**Possible Causes**
1. Communication with the Wi-Fi service failed.
2. The Wi-Fi chip communication is abnormal.
3. An unknown error has occurred.
**Solution**
1. Disable and then enable the Wi-Fi function again.
2. If the error persists, restart the device.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册