提交 dd09c5a2 编写于 作者: 张悦诶

new HarmonyAppProvison configuration file

Signed-off-by: N张悦诶 <zhangyue230@h-partners.com>
上级 07c451db
...@@ -71,3 +71,7 @@ httpRequest.request( ...@@ -71,3 +71,7 @@ httpRequest.request(
} }
); );
``` ```
## Samples
The following sample is provided to help you better understand how to develop the HTTP data request feature:
- [`Http`: HTTP Data Request (eTS) (API 8)](https://gitee.com/openharmony/app_samples/tree/master/Network/Http)
...@@ -122,3 +122,7 @@ The implementation is similar for UDPSocket and TCPSocket. The following uses th ...@@ -122,3 +122,7 @@ The implementation is similar for UDPSocket and TCPSocket. The following uses th
tcp.off('close'); tcp.off('close');
}, 30 * 1000); }, 30 * 1000);
``` ```
## Samples
The following sample is provided to help you better understand how to develop the socket connection feature:
- [`Socket`: Socket Connection (eTS) (API 8)](https://gitee.com/openharmony/app_samples/tree/master/Network/Socket)
...@@ -75,4 +75,4 @@ In this example, an application event is logged after the application startup ex ...@@ -75,4 +75,4 @@ In this example, an application event is logged after the application startup ex
The following sample is provided to help you better understand how to develop the application event logging feature: The following sample is provided to help you better understand how to develop the application event logging feature:
- [`JsDotTest`: Event Logging Test (JavaScript) (API 7)](https://gitee.com/openharmony/app_samples/tree/master/DFX/JsDotTest) - [`JsDotTest`: Event Logging Test (JavaScript) (API 8)](https://gitee.com/openharmony/app_samples/tree/master/DFX/JsDotTest)
# Ability Access Control # Ability Access Control
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> 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.
## Modules to Import ## Modules to Import
``` ```js
import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
``` ```
...@@ -26,7 +26,7 @@ Creates an **AtManager** instance, which is used for ability access control. ...@@ -26,7 +26,7 @@ Creates an **AtManager** instance, which is used for ability access control.
**Example** **Example**
``` ```js
var AtManager = abilityAccessCtrl.createAtManager(); var AtManager = abilityAccessCtrl.createAtManager();
``` ```
...@@ -57,7 +57,7 @@ Checks whether an application has been granted the specified permission. This AP ...@@ -57,7 +57,7 @@ Checks whether an application has been granted the specified permission. This AP
**Example** **Example**
``` ```js
var AtManager = abilityAccessCtrl.createAtManager(); var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; let tokenID = 0;
let promise = AtManager.verifyAccessToken(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); let promise = AtManager.verifyAccessToken(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
...@@ -92,7 +92,7 @@ Grants a user granted permission to an application. This API uses a promise to r ...@@ -92,7 +92,7 @@ Grants a user granted permission to an application. This API uses a promise to r
**Example** **Example**
``` ```js
var AtManager = abilityAccessCtrl.createAtManager(); var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; let tokenID = 0;
let promise = AtManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); let promise = AtManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
...@@ -124,7 +124,7 @@ Grants a user granted permission to an application. This API uses an asynchronou ...@@ -124,7 +124,7 @@ Grants a user granted permission to an application. This API uses an asynchronou
**Example** **Example**
``` ```js
var AtManager = abilityAccessCtrl.createAtManager(); var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; let tokenID = 0;
let permissionFlag = 1; let permissionFlag = 1;
...@@ -159,7 +159,7 @@ Revokes a user granted permission given to an application. This API uses a promi ...@@ -159,7 +159,7 @@ Revokes a user granted permission given to an application. This API uses a promi
**Example** **Example**
``` ```js
var AtManager = abilityAccessCtrl.createAtManager(); var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; let tokenID = 0;
let permissionFlag = 1; let permissionFlag = 1;
...@@ -190,7 +190,7 @@ Revokes a user granted permission given to an application. This API uses an asyn ...@@ -190,7 +190,7 @@ Revokes a user granted permission given to an application. This API uses an asyn
**Example** **Example**
``` ```js
var AtManager = abilityAccessCtrl.createAtManager(); var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; let tokenID = 0;
AtManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",permissionFlag, data => { AtManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",permissionFlag, data => {
...@@ -223,7 +223,7 @@ Obtains the flags of the specified permission of a given application. This API u ...@@ -223,7 +223,7 @@ Obtains the flags of the specified permission of a given application. This API u
**Example** **Example**
``` ```js
var AtManager = abilityAccessCtrl.createAtManager(); var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; let tokenID = 0;
let promise = AtManager.getPermissionFlags(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); let promise = AtManager.getPermissionFlags(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
## Modules to Import ## Modules to Import
``` ```js
import call from '@ohos.telephony.call'; import call from '@ohos.telephony.call';
``` ```
...@@ -30,7 +30,7 @@ Initiates a call. This API uses an asynchronous callback to return the execution ...@@ -30,7 +30,7 @@ Initiates a call. This API uses an asynchronous callback to return the execution
**Example** **Example**
``` ```js
call.dial("138xxxxxxxx", (err, data) => { call.dial("138xxxxxxxx", (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -57,7 +57,7 @@ Initiates a call. You can set call options as needed. This API uses an asynchron ...@@ -57,7 +57,7 @@ Initiates a call. You can set call options as needed. This API uses an asynchron
**Example** **Example**
``` ```js
call.dial("138xxxxxxxx", { call.dial("138xxxxxxxx", {
extras: false extras: false
}, (err, data) => { }, (err, data) => {
...@@ -91,7 +91,7 @@ Initiates a call. You can set call options as needed. This API uses a promise to ...@@ -91,7 +91,7 @@ Initiates a call. You can set call options as needed. This API uses a promise to
**Example** **Example**
``` ```js
let promise = call.dial("138xxxxxxxx", { let promise = call.dial("138xxxxxxxx", {
extras: false extras: false
}); });
...@@ -121,7 +121,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a ...@@ -121,7 +121,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a
**Example** **Example**
``` ```js
call.makeCall("138xxxxxxxx", err => { call.makeCall("138xxxxxxxx", err => {
console.log(`makeCall callback: err->${JSON.stringify(err)}`); console.log(`makeCall callback: err->${JSON.stringify(err)}`);
}); });
...@@ -152,7 +152,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a ...@@ -152,7 +152,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a
**Example** **Example**
``` ```js
let promise = call.makeCall("138xxxxxxxx"); let promise = call.makeCall("138xxxxxxxx");
promise.then(() => { promise.then(() => {
console.log(`makeCall success`); console.log(`makeCall success`);
...@@ -177,7 +177,7 @@ Checks whether a call is in progress. This API uses an asynchronous callback to ...@@ -177,7 +177,7 @@ Checks whether a call is in progress. This API uses an asynchronous callback to
**Example** **Example**
``` ```js
call.hasCall((err, data) => { call.hasCall((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -200,7 +200,7 @@ Checks whether a call is in progress. This API uses a promise to return the resu ...@@ -200,7 +200,7 @@ Checks whether a call is in progress. This API uses a promise to return the resu
**Example** **Example**
``` ```js
let promise = call.hasCall(); let promise = call.hasCall();
promise.then(data => { promise.then(data => {
console.log(`hasCall success, promise: data->${JSON.stringify(data)}`); console.log(`hasCall success, promise: data->${JSON.stringify(data)}`);
...@@ -226,7 +226,7 @@ Obtains the call status. This API uses an asynchronous callback to return the re ...@@ -226,7 +226,7 @@ Obtains the call status. This API uses an asynchronous callback to return the re
**Example** **Example**
``` ```js
call.getCallState((err, data) => { call.getCallState((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -249,7 +249,7 @@ Obtains the call status. This API uses a promise to return the result. ...@@ -249,7 +249,7 @@ Obtains the call status. This API uses a promise to return the result.
**Example** **Example**
``` ```js
let promise = call.getCallState(); let promise = call.getCallState();
promise.then(data => { promise.then(data => {
console.log(`getCallState success, promise: data->${JSON.stringify(data)}`); console.log(`getCallState success, promise: data->${JSON.stringify(data)}`);
...@@ -272,7 +272,7 @@ Checks whether a device supports voice calls. This API works in synchronous mode ...@@ -272,7 +272,7 @@ Checks whether a device supports voice calls. This API works in synchronous mode
| ------- | ------------------------------------------------------------ | | ------- | ------------------------------------------------------------ |
| boolean | - **true**: The device supports voice calls.<br>- **false**: The device does not support voice calls.| | boolean | - **true**: The device supports voice calls.<br>- **false**: The device does not support voice calls.|
``` ```js
let result = call.hasVoiceCapability(); let result = call.hasVoiceCapability();
console.log(`hasVoiceCapability: ${JSON.stringify(result)}`); console.log(`hasVoiceCapability: ${JSON.stringify(result)}`);
``` ```
...@@ -294,7 +294,7 @@ Checks whether the call number of the SIM card in the specified slot is an emerg ...@@ -294,7 +294,7 @@ Checks whether the call number of the SIM card in the specified slot is an emerg
**Example** **Example**
``` ```js
call.isEmergencyPhoneNumber("138xxxxxxxx", (err, data) => { call.isEmergencyPhoneNumber("138xxxxxxxx", (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -319,7 +319,7 @@ Checks whether the call number of the SIM card in the specified slot is an emerg ...@@ -319,7 +319,7 @@ Checks whether the call number of the SIM card in the specified slot is an emerg
**Example** **Example**
``` ```js
call.isEmergencyPhoneNumber("112", {slotId: 1}, (err, value) => { call.isEmergencyPhoneNumber("112", {slotId: 1}, (err, value) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -349,7 +349,7 @@ Checks whether the call number of the SIM card in the specified slot is an emerg ...@@ -349,7 +349,7 @@ Checks whether the call number of the SIM card in the specified slot is an emerg
**Example** **Example**
``` ```js
let promise = call.isEmergencyPhoneNumber("138xxxxxxxx", {slotId: 1}); let promise = call.isEmergencyPhoneNumber("138xxxxxxxx", {slotId: 1});
promise.then(data => { promise.then(data => {
console.log(`isEmergencyPhoneNumber success, promise: data->${JSON.stringify(data)}`); console.log(`isEmergencyPhoneNumber success, promise: data->${JSON.stringify(data)}`);
...@@ -375,7 +375,7 @@ Formats a phone number based on the specified ISO country code. This API uses an ...@@ -375,7 +375,7 @@ Formats a phone number based on the specified ISO country code. This API uses an
**Example** **Example**
``` ```js
call.formatPhoneNumber("138xxxxxxxx", (err, data) => { call.formatPhoneNumber("138xxxxxxxx", (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -400,7 +400,7 @@ Formats a phone number based on specified formatting options. This API uses an a ...@@ -400,7 +400,7 @@ Formats a phone number based on specified formatting options. This API uses an a
**Example** **Example**
``` ```js
call.formatPhoneNumber("138xxxxxxxx",{ call.formatPhoneNumber("138xxxxxxxx",{
countryCode: "CN" countryCode: "CN"
}, (err, data) => { }, (err, data) => {
...@@ -432,7 +432,7 @@ Formats a phone number based on specified formatting options. This API uses a pr ...@@ -432,7 +432,7 @@ Formats a phone number based on specified formatting options. This API uses a pr
**Example** **Example**
``` ```js
let promise = call.formatPhoneNumber("138xxxxxxxx", { let promise = call.formatPhoneNumber("138xxxxxxxx", {
countryCode: "CN" countryCode: "CN"
}); });
...@@ -465,7 +465,7 @@ All country codes are supported. ...@@ -465,7 +465,7 @@ All country codes are supported.
**Example** **Example**
``` ```js
call.formatPhoneNumberToE164("138xxxxxxxx",{ call.formatPhoneNumberToE164("138xxxxxxxx",{
countryCode: "CN" countryCode: "CN"
}, (err, data) => { }, (err, data) => {
...@@ -501,7 +501,7 @@ All country codes are supported. ...@@ -501,7 +501,7 @@ All country codes are supported.
**Example** **Example**
``` ```js
let promise = call.formatPhoneNumberToE164("138xxxxxxxx", { let promise = call.formatPhoneNumberToE164("138xxxxxxxx", {
countryCode: "CN" countryCode: "CN"
}); });
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
## Modules to Import ## Modules to Import
``` ```js
import contact from '@ohos.contact'; import contact from '@ohos.contact';
``` ```
...@@ -29,7 +29,7 @@ Adds a contact. This API uses an asynchronous callback to return the result. ...@@ -29,7 +29,7 @@ Adds a contact. This API uses an asynchronous callback to return the result.
**Example** **Example**
``` ```js
contact.addContact({ contact.addContact({
fullName: {fullName: 'xxx'}, fullName: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
...@@ -65,7 +65,7 @@ Adds a contact. This API uses a promise to return the result. ...@@ -65,7 +65,7 @@ Adds a contact. This API uses a promise to return the result.
**Example** **Example**
``` ```js
let promise = contact.addContact({ let promise = contact.addContact({
name: {fullName: 'xxx'}, name: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
...@@ -96,7 +96,7 @@ Deletes a contact based on the specified contact key. This API uses an asynchron ...@@ -96,7 +96,7 @@ Deletes a contact based on the specified contact key. This API uses an asynchron
**Example** **Example**
``` ```js
contact.deleteContact('xxx', (err) => { contact.deleteContact('xxx', (err) => {
if (err) { if (err) {
console.log(`deleteContact callback: err->${JSON.stringify(err)}`); console.log(`deleteContact callback: err->${JSON.stringify(err)}`);
...@@ -129,7 +129,7 @@ Deletes a contact based on the specified contact key. This API uses a promise to ...@@ -129,7 +129,7 @@ Deletes a contact based on the specified contact key. This API uses a promise to
**Example** **Example**
``` ```js
let promise = contact.deleteContact('xxx'); let promise = contact.deleteContact('xxx');
promise.then(() => { promise.then(() => {
console.log(`deleteContact success`); console.log(`deleteContact success`);
...@@ -157,7 +157,7 @@ Updates a contact based on the specified contact information. This API uses an a ...@@ -157,7 +157,7 @@ Updates a contact based on the specified contact information. This API uses an a
**Example** **Example**
``` ```js
contact.updateContact({ contact.updateContact({
name: {fullName: 'xxx'}, name: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
...@@ -190,7 +190,7 @@ Updates a contact based on the specified contact information and attributes. Thi ...@@ -190,7 +190,7 @@ Updates a contact based on the specified contact information and attributes. Thi
**Example** **Example**
``` ```js
contact.updateContact({ contact.updateContact({
fullName: {fullName: 'xxx'}, fullName: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
...@@ -229,7 +229,7 @@ Updates a contact based on the specified contact information and attributes. Thi ...@@ -229,7 +229,7 @@ Updates a contact based on the specified contact information and attributes. Thi
**Example** **Example**
``` ```js
let promise = contact.updateContact({ let promise = contact.updateContact({
fullName: {fullName: 'xxx'}, fullName: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
...@@ -262,7 +262,7 @@ Checks whether the ID of this contact is in the local address book. This API use ...@@ -262,7 +262,7 @@ Checks whether the ID of this contact is in the local address book. This API use
**Example** **Example**
``` ```js
contact.isLocalContact(/*id*/1, (err, data) => { contact.isLocalContact(/*id*/1, (err, data) => {
if (err) { if (err) {
console.log(`isLocalContact callback: err->${JSON.stringify(err)}`); console.log(`isLocalContact callback: err->${JSON.stringify(err)}`);
...@@ -295,7 +295,7 @@ Checks whether the ID of this contact is in the local address book. This API use ...@@ -295,7 +295,7 @@ Checks whether the ID of this contact is in the local address book. This API use
**Example** **Example**
``` ```js
let promise = contact.isLocalContact(/*id*/1); let promise = contact.isLocalContact(/*id*/1);
promise.then((data) => { promise.then((data) => {
console.log(`isLocalContact success: data->${JSON.stringify(data)}`); console.log(`isLocalContact success: data->${JSON.stringify(data)}`);
...@@ -323,7 +323,7 @@ Checks whether a contact is included in my card. This API uses an asynchronous c ...@@ -323,7 +323,7 @@ Checks whether a contact is included in my card. This API uses an asynchronous c
**Example** **Example**
``` ```js
contact.isMyCard(/*id*/1, (err, data) => { contact.isMyCard(/*id*/1, (err, data) => {
if (err) { if (err) {
console.log(`isMyCard callback: err->${JSON.stringify(err)}`); console.log(`isMyCard callback: err->${JSON.stringify(err)}`);
...@@ -356,7 +356,7 @@ Checks whether a contact is included in my card. This API uses a promise to retu ...@@ -356,7 +356,7 @@ Checks whether a contact is included in my card. This API uses a promise to retu
**Example** **Example**
``` ```js
let promise = contact.isMyCard(/*id*/1); let promise = contact.isMyCard(/*id*/1);
promise.then((data) => { promise.then((data) => {
console.log(`isMyCard success: data->${JSON.stringify(data)}`); console.log(`isMyCard success: data->${JSON.stringify(data)}`);
...@@ -383,7 +383,7 @@ Queries my card. This API uses an asynchronous callback to return the result. ...@@ -383,7 +383,7 @@ Queries my card. This API uses an asynchronous callback to return the result.
**Example** **Example**
``` ```js
contact.queryMyCard((err, data) => { contact.queryMyCard((err, data) => {
if (err) { if (err) {
console.log(`queryMyCard callback: err->${JSON.stringify(err)}`); console.log(`queryMyCard callback: err->${JSON.stringify(err)}`);
...@@ -412,7 +412,7 @@ Queries my card based on the specified contact attributes. This API uses an asyn ...@@ -412,7 +412,7 @@ Queries my card based on the specified contact attributes. This API uses an asyn
**Example** **Example**
``` ```js
contact.queryMyCard({ contact.queryMyCard({
attributes:['ATTR_EMAIL', 'ATTR_NAME'] attributes:['ATTR_EMAIL', 'ATTR_NAME']
}, (err, data) => { }, (err, data) => {
...@@ -447,7 +447,7 @@ Queries my card based on the specified contact attributes. This API uses a promi ...@@ -447,7 +447,7 @@ Queries my card based on the specified contact attributes. This API uses a promi
**Example** **Example**
``` ```js
let promise = contact.queryMyCard({ let promise = contact.queryMyCard({
attributes:['ATTR_EMAIL', 'ATTR_NAME'] attributes:['ATTR_EMAIL', 'ATTR_NAME']
}); });
...@@ -478,7 +478,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a ...@@ -478,7 +478,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a
**Example** **Example**
``` ```js
contact.selectContact((err, data) => { contact.selectContact((err, data) => {
if (err) { if (err) {
console.log(`selectContact callback: err->${JSON.stringify(err)}`); console.log(`selectContact callback: err->${JSON.stringify(err)}`);
...@@ -508,7 +508,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a ...@@ -508,7 +508,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a
**Example** **Example**
``` ```js
let promise = contact.selectContact(); let promise = contact.selectContact();
promise.then((data) => { promise.then((data) => {
console.log(`selectContact success: data->${JSON.stringify(data)}`); console.log(`selectContact success: data->${JSON.stringify(data)}`);
...@@ -536,7 +536,7 @@ Queries a contact based on the specified key. This API uses an asynchronous call ...@@ -536,7 +536,7 @@ Queries a contact based on the specified key. This API uses an asynchronous call
**Example** **Example**
``` ```js
contact.queryContact('xxx', (err, data) => { contact.queryContact('xxx', (err, data) => {
if (err) { if (err) {
console.log(`queryContact callback: err->${JSON.stringify(err)}`); console.log(`queryContact callback: err->${JSON.stringify(err)}`);
...@@ -566,7 +566,7 @@ Queries contacts based on the specified key and application. This API uses an as ...@@ -566,7 +566,7 @@ Queries contacts based on the specified key and application. This API uses an as
**Example** **Example**
``` ```js
contact.queryContact('xxx', { contact.queryContact('xxx', {
holderId: 0 holderId: 0
}, (err, data) => { }, (err, data) => {
...@@ -598,7 +598,7 @@ Queries contacts based on the specified key and attributes. This API uses an asy ...@@ -598,7 +598,7 @@ Queries contacts based on the specified key and attributes. This API uses an asy
**Example** **Example**
``` ```js
contact.queryContact('xxx', { contact.queryContact('xxx', {
attributes: ["ATTR_EMAIL", "ATTR_NAME"] attributes: ["ATTR_EMAIL", "ATTR_NAME"]
}, (err, data) => { }, (err, data) => {
...@@ -631,7 +631,7 @@ Queries contacts based on the specified key, application, and attributes. This A ...@@ -631,7 +631,7 @@ Queries contacts based on the specified key, application, and attributes. This A
**Example** **Example**
``` ```js
contact.queryContact('xxx', { contact.queryContact('xxx', {
holderId: 0 holderId: 0
}, { }, {
...@@ -670,7 +670,7 @@ Queries contacts based on the specified key, application, and attributes. This A ...@@ -670,7 +670,7 @@ Queries contacts based on the specified key, application, and attributes. This A
**Example** **Example**
``` ```js
let promise = contact.queryContact('xxx', { let promise = contact.queryContact('xxx', {
holderId: 0 holderId: 0
}, { }, {
...@@ -701,7 +701,7 @@ Queries all contacts. This API uses an asynchronous callback to return the resul ...@@ -701,7 +701,7 @@ Queries all contacts. This API uses an asynchronous callback to return the resul
**Example** **Example**
``` ```js
contact.queryContacts((err, data) => { contact.queryContacts((err, data) => {
if (err) { if (err) {
console.log(`queryContacts callback: err->${JSON.stringify(err)}`); console.log(`queryContacts callback: err->${JSON.stringify(err)}`);
...@@ -730,7 +730,7 @@ Queries all contacts based on the specified application. This API uses an asynch ...@@ -730,7 +730,7 @@ Queries all contacts based on the specified application. This API uses an asynch
**Example** **Example**
``` ```js
contact.queryContacts({ contact.queryContacts({
holderId: 0 holderId: 0
}, (err, data) => { }, (err, data) => {
...@@ -761,7 +761,7 @@ Queries all contacts based on the specified attributes. This API uses an asynchr ...@@ -761,7 +761,7 @@ Queries all contacts based on the specified attributes. This API uses an asynchr
**Example** **Example**
``` ```js
contact.queryContacts({ contact.queryContacts({
attributes: ["ATTR_EMAIL", "ATTR_NAME"] attributes: ["ATTR_EMAIL", "ATTR_NAME"]
}, (err, data) => { }, (err, data) => {
...@@ -793,7 +793,7 @@ Queries all contacts based on the specified application and attributes. This API ...@@ -793,7 +793,7 @@ Queries all contacts based on the specified application and attributes. This API
**Example** **Example**
``` ```js
contact.queryContacts({ contact.queryContacts({
holderId: 0 holderId: 0
}, { }, {
...@@ -831,7 +831,7 @@ Queries all contacts based on the specified application and attributes. This API ...@@ -831,7 +831,7 @@ Queries all contacts based on the specified application and attributes. This API
**Example** **Example**
``` ```js
let promise = contact.queryContacts({ let promise = contact.queryContacts({
holderId: 0 holderId: 0
}, { }, {
...@@ -863,7 +863,7 @@ Queries contacts based on the specified phone number. This API uses an asynchron ...@@ -863,7 +863,7 @@ Queries contacts based on the specified phone number. This API uses an asynchron
**Example** **Example**
``` ```js
contact.queryContactsByPhoneNumber('138xxxxxxxx', (err, data) => { contact.queryContactsByPhoneNumber('138xxxxxxxx', (err, data) => {
if (err) { if (err) {
console.log(`queryContactsByPhoneNumber callback: err->${JSON.stringify(err)}`); console.log(`queryContactsByPhoneNumber callback: err->${JSON.stringify(err)}`);
...@@ -893,7 +893,7 @@ Queries contacts based on the specified phone number and application. This API u ...@@ -893,7 +893,7 @@ Queries contacts based on the specified phone number and application. This API u
**Example** **Example**
``` ```js
contact.queryContactsByPhoneNumber('138xxxxxxxx', { contact.queryContactsByPhoneNumber('138xxxxxxxx', {
holderId: 0 holderId: 0
}, (err, data) => { }, (err, data) => {
...@@ -925,7 +925,7 @@ Queries contacts based on the specified phone number and attributes. This API us ...@@ -925,7 +925,7 @@ Queries contacts based on the specified phone number and attributes. This API us
**Example** **Example**
``` ```js
contact.queryContactsByPhoneNumber('138xxxxxxxx', { contact.queryContactsByPhoneNumber('138xxxxxxxx', {
attributes: ["ATTR_EMAIL", "ATTR_NAME"] attributes: ["ATTR_EMAIL", "ATTR_NAME"]
}, (err, data) => { }, (err, data) => {
...@@ -958,7 +958,7 @@ Queries contacts based on the specified phone number, application, and attribute ...@@ -958,7 +958,7 @@ Queries contacts based on the specified phone number, application, and attribute
**Example** **Example**
``` ```js
contact.queryContactsByPhoneNumber('138xxxxxxxx', { contact.queryContactsByPhoneNumber('138xxxxxxxx', {
holderId: 0 holderId: 0
}, { }, {
...@@ -997,7 +997,7 @@ Queries contacts based on the specified phone number, application, and attribute ...@@ -997,7 +997,7 @@ Queries contacts based on the specified phone number, application, and attribute
**Example** **Example**
``` ```js
let promise = contact.queryContactsByPhoneNumber('138xxxxxxxx', { let promise = contact.queryContactsByPhoneNumber('138xxxxxxxx', {
holderId: 0 holderId: 0
}, { }, {
...@@ -1029,7 +1029,7 @@ Queries contacts based on the specified email address. This API uses an asynchro ...@@ -1029,7 +1029,7 @@ Queries contacts based on the specified email address. This API uses an asynchro
**Example** **Example**
``` ```js
contact.queryContactsByEmail('xxx@email.com', (err, data) => { contact.queryContactsByEmail('xxx@email.com', (err, data) => {
if (err) { if (err) {
console.log(`queryContactsByEmail callback: err->${JSON.stringify(err)}`); console.log(`queryContactsByEmail callback: err->${JSON.stringify(err)}`);
...@@ -1059,7 +1059,7 @@ Queries contacts based on the specified email address and application. This API ...@@ -1059,7 +1059,7 @@ Queries contacts based on the specified email address and application. This API
**Example** **Example**
``` ```js
contact.queryContactsByEmail('xxx@email.com', { contact.queryContactsByEmail('xxx@email.com', {
holderId: 0 holderId: 0
}, (err, data) => { }, (err, data) => {
...@@ -1091,7 +1091,7 @@ Queries contacts based on the specified email address and attributes. This API u ...@@ -1091,7 +1091,7 @@ Queries contacts based on the specified email address and attributes. This API u
**Example** **Example**
``` ```js
contact.queryContactsByEmail('xxx@email.com', { contact.queryContactsByEmail('xxx@email.com', {
attributes: ["ATTR_EMAIL", "ATTR_NAME"] attributes: ["ATTR_EMAIL", "ATTR_NAME"]
}, (err, data) => { }, (err, data) => {
...@@ -1124,7 +1124,7 @@ Queries contacts based on the specified email address, application, and attribut ...@@ -1124,7 +1124,7 @@ Queries contacts based on the specified email address, application, and attribut
**Example** **Example**
``` ```js
contact.queryContactsByEmail('xxx@email.com', { contact.queryContactsByEmail('xxx@email.com', {
holderId: 0 holderId: 0
}, { }, {
...@@ -1163,7 +1163,7 @@ Queries contacts based on the specified email address, application, and attribut ...@@ -1163,7 +1163,7 @@ Queries contacts based on the specified email address, application, and attribut
**Example** **Example**
``` ```js
let promise = contact.queryContactsByEmail('xxx@email.com', { let promise = contact.queryContactsByEmail('xxx@email.com', {
holderId: 0 holderId: 0
}, { }, {
...@@ -1194,7 +1194,7 @@ Queries all groups of this contact. This API uses an asynchronous callback to re ...@@ -1194,7 +1194,7 @@ Queries all groups of this contact. This API uses an asynchronous callback to re
**Example** **Example**
``` ```js
contact.queryGroups((err, data) => { contact.queryGroups((err, data) => {
if (err) { if (err) {
console.log(`queryGroups callback: err->${JSON.stringify(err)}`); console.log(`queryGroups callback: err->${JSON.stringify(err)}`);
...@@ -1223,7 +1223,7 @@ Queries all groups of this contact based on the specified application. This API ...@@ -1223,7 +1223,7 @@ Queries all groups of this contact based on the specified application. This API
**Example** **Example**
``` ```js
contact.queryGroups({ contact.queryGroups({
holderId: 0 holderId: 0
}, (err, data) => { }, (err, data) => {
...@@ -1258,7 +1258,7 @@ Queries all groups of this contact based on the specified application. This API ...@@ -1258,7 +1258,7 @@ Queries all groups of this contact based on the specified application. This API
**Example** **Example**
``` ```js
let promise = contact.queryGroups({ let promise = contact.queryGroups({
holderId: 0 holderId: 0
}); });
...@@ -1287,7 +1287,7 @@ Queries all applications that have created contacts. This API uses an asynchrono ...@@ -1287,7 +1287,7 @@ Queries all applications that have created contacts. This API uses an asynchrono
**Example** **Example**
``` ```js
contact.queryHolders((err, data) => { contact.queryHolders((err, data) => {
if (err) { if (err) {
console.log(`queryHolders callback: err->${JSON.stringify(err)}`); console.log(`queryHolders callback: err->${JSON.stringify(err)}`);
...@@ -1315,7 +1315,7 @@ Queries all applications that have created contacts. This API uses a promise to ...@@ -1315,7 +1315,7 @@ Queries all applications that have created contacts. This API uses a promise to
**Example** **Example**
``` ```js
let promise = contact.queryHolders(); let promise = contact.queryHolders();
promise.then((data) => { promise.then((data) => {
console.log(`queryHolders success: data->${JSON.stringify(data)}`); console.log(`queryHolders success: data->${JSON.stringify(data)}`);
...@@ -1343,7 +1343,7 @@ Queries the key of a contact based on the specified contact ID. This API uses an ...@@ -1343,7 +1343,7 @@ Queries the key of a contact based on the specified contact ID. This API uses an
**Example** **Example**
``` ```js
contact.queryKey(/*id*/1, (err, data) => { contact.queryKey(/*id*/1, (err, data) => {
if (err) { if (err) {
console.log(`queryKey callback: err->${JSON.stringify(err)}`); console.log(`queryKey callback: err->${JSON.stringify(err)}`);
...@@ -1373,7 +1373,7 @@ Queries the key of a contact based on the specified contact ID and application. ...@@ -1373,7 +1373,7 @@ Queries the key of a contact based on the specified contact ID and application.
**Example** **Example**
``` ```js
contact.queryKey(id, { contact.queryKey(id, {
holderId:1 holderId:1
}, (err, data) => { }, (err, data) => {
...@@ -1409,7 +1409,7 @@ Queries the key of a contact based on the specified contact ID and application. ...@@ -1409,7 +1409,7 @@ Queries the key of a contact based on the specified contact ID and application.
**Example** **Example**
``` ```js
let promise = contact.queryKey(id, { let promise = contact.queryKey(id, {
holderId: 0 holderId: 0
}); });
...@@ -1462,7 +1462,7 @@ Defines a contact. ...@@ -1462,7 +1462,7 @@ Defines a contact.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let myContact = { let myContact = {
phoneNumbers: [{ phoneNumbers: [{
phoneNumber: "138xxxxxxxx" phoneNumber: "138xxxxxxxx"
...@@ -1480,7 +1480,7 @@ let myContact = { ...@@ -1480,7 +1480,7 @@ let myContact = {
Or, create data by configuring a new Contact object. Or, create data by configuring a new Contact object.
``` ```js
let myContact = new contact.Contact(); let myContact = new contact.Contact();
let name = new contact.Name(); let name = new contact.Name();
name.fullName = "fullName"; name.fullName = "fullName";
...@@ -1508,7 +1508,7 @@ If **null** is passed, all attributes are queried by default. ...@@ -1508,7 +1508,7 @@ If **null** is passed, all attributes are queried by default.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let contactAttributes = { let contactAttributes = {
attributes: [ attributes: [
contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_EMAIL,
...@@ -1521,7 +1521,7 @@ let contactAttributes = { ...@@ -1521,7 +1521,7 @@ let contactAttributes = {
Or, create data by configuring a **ContactAttributes** object. Or, create data by configuring a **ContactAttributes** object.
``` ```js
let contactAttributes = new contact.ContactAttributes(); let contactAttributes = new contact.ContactAttributes();
contactAttributes.attributes = ["ATTR_EMAIL"]; contactAttributes.attributes = ["ATTR_EMAIL"];
``` ```
...@@ -1555,7 +1555,7 @@ Enumerates contact attributes. ...@@ -1555,7 +1555,7 @@ Enumerates contact attributes.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let attributes = [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME, contact.Attribute.ATTR_PHONE]; let attributes = [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME, contact.Attribute.ATTR_PHONE];
``` ```
...@@ -1591,7 +1591,7 @@ Defines a contact's email. ...@@ -1591,7 +1591,7 @@ Defines a contact's email.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let email = { let email = {
email: "xxx@email.com", email: "xxx@email.com",
displayName: "displayName" displayName: "displayName"
...@@ -1601,7 +1601,7 @@ let email = { ...@@ -1601,7 +1601,7 @@ let email = {
Or, create data by configuring an **Email** object. Or, create data by configuring an **Email** object.
``` ```js
let email = new contact.Email(); let email = new contact.Email();
email.email = "xxx@email.com"; email.email = "xxx@email.com";
``` ```
...@@ -1624,7 +1624,7 @@ Defines an application that creates the contact. ...@@ -1624,7 +1624,7 @@ Defines an application that creates the contact.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let holder = { let holder = {
holderId: 0 holderId: 0
}; };
...@@ -1632,7 +1632,7 @@ let holder = { ...@@ -1632,7 +1632,7 @@ let holder = {
Or, create data by configuring a **Holder** object. Or, create data by configuring a **Holder** object.
``` ```js
let holder = new contact.Holder(); let holder = new contact.Holder();
holder.holderId = 0; holder.holderId = 0;
``` ```
...@@ -1668,7 +1668,7 @@ Defines a contact's event. ...@@ -1668,7 +1668,7 @@ Defines a contact's event.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let event = { let event = {
eventDate: "xxxxxx" eventDate: "xxxxxx"
}; };
...@@ -1676,7 +1676,7 @@ let event = { ...@@ -1676,7 +1676,7 @@ let event = {
Or, create data by configuring an **Event** object. Or, create data by configuring an **Event** object.
``` ```js
let event = new contact.Event(); let event = new contact.Event();
event.eventDate = "xxxxxx"; event.eventDate = "xxxxxx";
``` ```
...@@ -1698,7 +1698,7 @@ Defines a contact group. ...@@ -1698,7 +1698,7 @@ Defines a contact group.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let group = { let group = {
groupId: 1, groupId: 1,
title: "title" title: "title"
...@@ -1707,7 +1707,7 @@ let group = { ...@@ -1707,7 +1707,7 @@ let group = {
Or, create data by configuring a **Group** object. Or, create data by configuring a **Group** object.
``` ```js
let group = new contact.Group(); let group = new contact.Group();
group.title = "title"; group.title = "title";
``` ```
...@@ -1747,7 +1747,7 @@ Enumerates IM addresses. ...@@ -1747,7 +1747,7 @@ Enumerates IM addresses.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let imAddress = { let imAddress = {
imAddress: "imAddress", imAddress: "imAddress",
labelName: "labelName" labelName: "labelName"
...@@ -1757,7 +1757,7 @@ let imAddress = { ...@@ -1757,7 +1757,7 @@ let imAddress = {
Or, create data by configuring an **ImAddress** object. Or, create data by configuring an **ImAddress** object.
``` ```js
let imAddress = new contact.ImAddress(); let imAddress = new contact.ImAddress();
imAddress.imAddress = "imAddress"; imAddress.imAddress = "imAddress";
``` ```
...@@ -1786,7 +1786,7 @@ Defines a contact's name. ...@@ -1786,7 +1786,7 @@ Defines a contact's name.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let name = { let name = {
familyName: "familyName", familyName: "familyName",
fullName: "fullName" fullName: "fullName"
...@@ -1795,7 +1795,7 @@ let name = { ...@@ -1795,7 +1795,7 @@ let name = {
Or, create data by configuring a **Name** object. Or, create data by configuring a **Name** object.
``` ```js
let name = new contact.Name(); let name = new contact.Name();
name.familyName = "familyName"; name.familyName = "familyName";
name.fullName = "fullName"; name.fullName = "fullName";
...@@ -1817,7 +1817,7 @@ Defines a contact's nickname. ...@@ -1817,7 +1817,7 @@ Defines a contact's nickname.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let nickName = { let nickName = {
nickName: "nickName" nickName: "nickName"
}; };
...@@ -1825,7 +1825,7 @@ let nickName = { ...@@ -1825,7 +1825,7 @@ let nickName = {
Or, create data by configuring a **NickName** object. Or, create data by configuring a **NickName** object.
``` ```js
let nickName = new contact.NickName(); let nickName = new contact.NickName();
nickName.nickName = "nickName"; nickName.nickName = "nickName";
``` ```
...@@ -1846,7 +1846,7 @@ Defines a contact's note. ...@@ -1846,7 +1846,7 @@ Defines a contact's note.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let note = { let note = {
noteContent: "noteContent" noteContent: "noteContent"
}; };
...@@ -1854,7 +1854,7 @@ let note = { ...@@ -1854,7 +1854,7 @@ let note = {
Or, create data by configuring a **Note** object. Or, create data by configuring a **Note** object.
``` ```js
let note = new contact.Note(); let note = new contact.Note();
note.noteContent = "noteContent"; note.noteContent = "noteContent";
``` ```
...@@ -1876,7 +1876,7 @@ Defines a contact's organization. ...@@ -1876,7 +1876,7 @@ Defines a contact's organization.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let organization = { let organization = {
name: "name", name: "name",
title: "title" title: "title"
...@@ -1885,7 +1885,7 @@ let organization = { ...@@ -1885,7 +1885,7 @@ let organization = {
Or, create data by configuring an **Organization** object. Or, create data by configuring an **Organization** object.
``` ```js
let organization = new contact.Organization(); let organization = new contact.Organization();
organization.name = "name"; organization.name = "name";
organization.title = "title"; organization.title = "title";
...@@ -1939,7 +1939,7 @@ Defines a contact's phone number. ...@@ -1939,7 +1939,7 @@ Defines a contact's phone number.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let phoneNumber = { let phoneNumber = {
phoneNumber: "138xxxxxxxx", phoneNumber: "138xxxxxxxx",
labelId: contact.PhoneNumber.NUM_HOME labelId: contact.PhoneNumber.NUM_HOME
...@@ -1948,7 +1948,7 @@ let phoneNumber = { ...@@ -1948,7 +1948,7 @@ let phoneNumber = {
Or, create data by configuring a new **PhoneNumber** object. Or, create data by configuring a new **PhoneNumber** object.
``` ```js
let phoneNumber = new contact.PhoneNumber(); let phoneNumber = new contact.PhoneNumber();
phoneNumber.phoneNumber = "138xxxxxxxx"; phoneNumber.phoneNumber = "138xxxxxxxx";
``` ```
...@@ -1969,7 +1969,7 @@ Defines a contact's portrait. ...@@ -1969,7 +1969,7 @@ Defines a contact's portrait.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let portrait = { let portrait = {
uri: "uri" uri: "uri"
}; };
...@@ -1977,7 +1977,7 @@ let portrait = { ...@@ -1977,7 +1977,7 @@ let portrait = {
Or, create data by configuring a new **Portrait** object. Or, create data by configuring a new **Portrait** object.
``` ```js
let portrait = new contact.Portrait(); let portrait = new contact.Portrait();
portrait.uri = "uri"; portrait.uri = "uri";
``` ```
...@@ -2020,7 +2020,7 @@ Defines a contact's postal address. ...@@ -2020,7 +2020,7 @@ Defines a contact's postal address.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let postalAddress = { let postalAddress = {
city: "city" city: "city"
}; };
...@@ -2028,7 +2028,7 @@ let postalAddress = { ...@@ -2028,7 +2028,7 @@ let postalAddress = {
Or, create data by configuring a new **PostalAddress** object. Or, create data by configuring a new **PostalAddress** object.
``` ```js
let postalAddress = new contact.PostalAddress(); let postalAddress = new contact.PostalAddress();
postalAddress.city = "city"; postalAddress.city = "city";
``` ```
...@@ -2075,7 +2075,7 @@ Defines a contact's relationship. ...@@ -2075,7 +2075,7 @@ Defines a contact's relationship.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let relation = { let relation = {
relationName: "relationName", relationName: "relationName",
labelId: contact.Relation.RELATION_ASSISTANT labelId: contact.Relation.RELATION_ASSISTANT
...@@ -2084,7 +2084,7 @@ let relation = { ...@@ -2084,7 +2084,7 @@ let relation = {
Or, create data by configuring a new **Relation** object. Or, create data by configuring a new **Relation** object.
``` ```js
let relation = new contact.Relation(); let relation = new contact.Relation();
relation.relationName = "relationName"; relation.relationName = "relationName";
relation.labelId = contact.Relation.RELATION_ASSISTANT; relation.labelId = contact.Relation.RELATION_ASSISTANT;
...@@ -2121,7 +2121,7 @@ Defines a contact's SIP address. ...@@ -2121,7 +2121,7 @@ Defines a contact's SIP address.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
var sipAddress = { var sipAddress = {
sipAddress: "sipAddress" sipAddress: "sipAddress"
}; };
...@@ -2129,7 +2129,7 @@ var sipAddress = { ...@@ -2129,7 +2129,7 @@ var sipAddress = {
Or, create data by configuring a new **SipAddress** object. Or, create data by configuring a new **SipAddress** object.
``` ```js
let sipAddress = new contact.SipAddress(); let sipAddress = new contact.SipAddress();
sipAddress.sipAddress = "sipAddress"; sipAddress.sipAddress = "sipAddress";
``` ```
...@@ -2150,7 +2150,7 @@ Defines a contact's website. ...@@ -2150,7 +2150,7 @@ Defines a contact's website.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let website = { let website = {
website: "website" website: "website"
}; };
...@@ -2158,7 +2158,7 @@ let website = { ...@@ -2158,7 +2158,7 @@ let website = {
Or, create data by configuring a new **Website** object. Or, create data by configuring a new **Website** object.
``` ```js
let website = new contact.Website(); let website = new contact.Website();
website.website = "website"; website.website = "website";
``` ```
# XML-to-JavaScript Conversion # XML-to-JavaScript Conversion
> **NOTE** > **NOTE**<br/>
> 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.
## Modules to Import ## Modules to Import
``` ```js
import convertxml from '@ohos.convertxml'; import convertxml from '@ohos.convertxml';
``` ```
## System Capabilities
SystemCapability.Utils.Lang
## ConvertXML ## ConvertXML
...@@ -23,61 +19,66 @@ convert(xml: string, options?: ConvertOptions) : Object ...@@ -23,61 +19,66 @@ convert(xml: string, options?: ConvertOptions) : Object
Converts an XML text into a JavaScript object. Converts an XML text into a JavaScript object.
**System capability**: SystemCapability.Utils.Lang
- Parameters
| Name| Type| Mandatory| Description| **Parameters**
| ------- | --------------------------------- | ---- | ------------------ |
| xml | string | Yes| XML text to convert.|
| options | [ConvertOptions](#convertoptions) | No| Settings of the convert operation.|
- Return value | Name | Type | Mandatory| Description |
| ------- | --------------------------------- | ---- | --------------- |
| xml | string | Yes | XML text to convert.|
| options | [ConvertOptions](#convertoptions) | No | Options for coversion. |
| Type| Description| **Return value**
| ------ | ---------------------------- |
| Object | JavaScript object.|
- Example | Type | Description |
| ------ | ---------------------------- |
| Object | JavaScript object.|
```js **Example**
let xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
let conv = new convertxml.ConvertXML();
let options = {trim : false, declarationKey:"_declaration",
instructionKey : "_instruction", attributesKey : "_attributes",
textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype",
commentKey : "_comment", parentKey : "_parent", typeKey : "_type",
nameKey : "_name", elementsKey : "_elements"}
let result = JSON.stringify(conv.convert(xml, options));
console.log(result)
```
```js
let xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
let conv = new convertxml.ConvertXML();
let options = {trim : false, declarationKey:"_declaration",
instructionKey : "_instruction", attributesKey : "_attributes",
textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype",
commentKey : "_comment", parentKey : "_parent", typeKey : "_type",
nameKey : "_name", elementsKey : "_elements"}
let result = JSON.stringify(conv.convert(xml, options));
console.log(result)
```
## ConvertOptions ## ConvertOptions
| Name| Type| Mandatory| Description| Options for coversion.
**System capability**: SystemCapability.Utils.Lang
| Name | Type| Mandatory| Description |
| ----------------- | -------- | ---- | ----------------------------------------------------------- | | ----------------- | -------- | ---- | ----------------------------------------------------------- |
| trim | boolean | Yes| Whether to trim the whitespace characters before and after the text. The default value is **false**.| | trim | boolean | Yes | Whether to trim the whitespace characters before and after the text. The default value is **false**. |
| ignoreDeclaration | boolean | No| Whether to ignore the XML declaration. The default value is **false**.| | ignoreDeclaration | boolean | No | Whether to ignore the XML declaration. The default value is **false**. |
| ignoreInstruction | boolean | No| Whether to ignore the XML processing instruction. The default value is **false**.| | ignoreInstruction | boolean | No | Whether to ignore the XML processing instruction. The default value is **false**. |
| ignoreAttributes | boolean | No| Whether to print attributes across multiple lines and indent attributes. The default value is **false**.| | ignoreAttributes | boolean | No | Whether to print attributes across multiple lines and indent attributes. The default value is **false**. |
| ignoreComment | boolean | No| Whether to ignore element comments. The default value is **false**.| | ignoreComment | boolean | No | Whether to ignore element comments. The default value is **false**. |
| ignoreCDATA | boolean | No| Whether to ignore the element's CDATA information. The default value is **false**.| | ignoreCDATA | boolean | No | Whether to ignore the element's CDATA information. The default value is **false**. |
| ignoreDoctype | boolean | No| Whether to ignore the element's Doctype information. The default value is **false**.| | ignoreDoctype | boolean | No | Whether to ignore the element's Doctype information. The default value is **false**. |
| ignoreText | boolean | No| Whether to ignore the element's text information. The default value is **false**.| | ignoreText | boolean | No | Whether to ignore the element's text information. The default value is **false**. |
| declarationKey | string | Yes| Name of the attribute key for **declaration** in the output object. The default value is **_declaration**.| | declarationKey | string | Yes | Name of the attribute key for **declaration** in the output object. The default value is **_declaration**.|
| instructionKey | string | Yes| Name of the attribute key for **instruction** in the output object. The default value is **_instruction**.| | instructionKey | string | Yes | Name of the attribute key for **instruction** in the output object. The default value is **_instruction**.|
| attributesKey | string | Yes| Name of the attribute key for **attributes** in the output object. The default value is **_attributes**.| | attributesKey | string | Yes | Name of the attribute key for **attributes** in the output object. The default value is **_attributes**. |
| textKey | string | Yes| Name of the attribute key for **text** in the output object. The default value is **_text**.| | textKey | string | Yes | Name of the attribute key for **text** in the output object. The default value is **_text**. |
| cdataKey | string | Yes| Name of the attribute key for **CDATA** in the output object. The default value is **_cdata**.| | cdataKey | string | Yes | Name of the attribute key for **CDATA** in the output object. The default value is **_cdata**. |
| doctypeKey | string | Yes| Name of the attribute key for **Doctype** in the output object. The default value is **_doctype**.| | doctypeKey | string | Yes | Name of the attribute key for **Doctype** in the output object. The default value is **_doctype**. |
| commentKey | string | Yes| Name of the attribute key for **comment** in the output object. The default value is **_comment**.| | commentKey | string | Yes | Name of the attribute key for **comment** in the output object. The default value is **_comment**. |
| parentKey | string | Yes| Name of the attribute key for **parent** in the output object. The default value is **_parent**.| | parentKey | string | Yes | Name of the attribute key for **parent** in the output object. The default value is **_parent**. |
| typeKey | string | Yes| Name of the attribute key for **type** in the output object. The default value is **_type**.| | typeKey | string | Yes | Name of the attribute key for **type** in the output object. The default value is **_type**. |
| nameKey | string | Yes| Name of the attribute key for **name** in the output object. The default value is **_name**.| | nameKey | string | Yes | Name of the attribute key for **name** in the output object. The default value is **_name**. |
| elementsKey | string | Yes| Name of the attribute key for **elements** in the output object. The default value is **_elements**.| | elementsKey | string | Yes | Name of the attribute key for **elements** in the output object. The default value is **_elements**. |
# Display # Display
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
...@@ -58,13 +58,12 @@ Obtains the default display object. ...@@ -58,13 +58,12 @@ Obtains the default display object.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core **System capabilities**: SystemCapability.WindowManager.WindowManager.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[Display](#display)&gt; | Yes| Callback used to return the default display object.| | callback | AsyncCallback&lt;[Display](#display)&gt; | Yes| Callback used to return the default display object.|
- Example **Example**
```js ```js
var displayClass = null; var displayClass = null;
display.getDefaultDisplay((err, data) => { display.getDefaultDisplay((err, data) => {
...@@ -85,13 +84,13 @@ Obtains the default display object. ...@@ -85,13 +84,13 @@ Obtains the default display object.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core **System capabilities**: SystemCapability.WindowManager.WindowManager.Core
- Return value **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ---------------------------------------------- | | ---------------------------------- | ---------------------------------------------- |
| Promise&lt;[Display](#display)&gt; | Promise used to return the default display object.| | Promise&lt;[Display](#display)&gt; | Promise used to return the default display object.|
- Example **Example**
```js ```js
let promise = display.getDefaultDisplay(); let promise = display.getDefaultDisplay();
...@@ -110,13 +109,13 @@ Obtains all the display objects. ...@@ -110,13 +109,13 @@ Obtains all the display objects.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core **System capabilities**: SystemCapability.WindowManager.WindowManager.Core
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------------- | ---- | ------------------------------- | | -------- | ---------------------------------------------------- | ---- | ------------------------------- |
| callback | AsyncCallback&lt;Array&lt;[Display](#display)&gt;&gt; | Yes | Callback used to return all the display objects.| | callback | AsyncCallback&lt;Array&lt;[Display](#display)&gt;&gt; | Yes | Callback used to return all the display objects.|
- Example **Example**
```js ```js
display.getAllDisplay((err, data) => { display.getAllDisplay((err, data) => {
...@@ -136,13 +135,13 @@ Obtains all the display objects. ...@@ -136,13 +135,13 @@ Obtains all the display objects.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core **System capabilities**: SystemCapability.WindowManager.WindowManager.Core
- Return value **Return value**
| Type | Description | | Type | Description |
| ----------------------------------------------- | ------------------------------------------------------- | | ----------------------------------------------- | ------------------------------------------------------- |
| Promise&lt;Array&lt;[Display](#display)&gt;&gt; | Promise used to return an array containing all the display objects.| | Promise&lt;Array&lt;[Display](#display)&gt;&gt; | Promise used to return an array containing all the display objects.|
- Example **Example**
```js ```js
let promise = display.getAllDisplay(); let promise = display.getAllDisplay();
...@@ -161,14 +160,13 @@ Enables listening. ...@@ -161,14 +160,13 @@ Enables listening.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core **System capabilities**: SystemCapability.WindowManager.WindowManager.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Listening type. The available values are as follows:<br>-&nbsp;**add**: listening for whether a display is added<br>-&nbsp;**remove**: listening for whether a display is removed<br>-&nbsp;**change**: listening for whether a display is changed| | type | string | Yes| Listening type. The available values are as follows:<br>-&nbsp;**add**: listening for whether a display is added<br>-&nbsp;**remove**: listening for whether a display is removed<br>-&nbsp;**change**: listening for whether a display is changed|
| callback | Callback&lt;number&gt; | Yes| Callback used to return the ID of the display.| | callback | Callback&lt;number&gt; | Yes| Callback used to return the ID of the display.|
- Example **Example**
```js ```js
var type = "add"; var type = "add";
var callback = (data) => { var callback = (data) => {
...@@ -186,14 +184,13 @@ Disables listening. ...@@ -186,14 +184,13 @@ Disables listening.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core **System capabilities**: SystemCapability.WindowManager.WindowManager.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Listening type. The available values are as follows:<br>-&nbsp;**add**: listening for whether a display is added<br>-&nbsp;**remove**: listening for whether a display is removed<br>-&nbsp;**change**: listening for whether a display is changed| | type | string | Yes| Listening type. The available values are as follows:<br>-&nbsp;**add**: listening for whether a display is added<br>-&nbsp;**remove**: listening for whether a display is removed<br>-&nbsp;**change**: listening for whether a display is changed|
| callback | Callback&lt;number&gt; | No| Callback used to return the ID of the display.| | callback | Callback&lt;number&gt; | No| Callback used to return the ID of the display.|
- Example **Example**
```js ```js
var type = "remove"; var type = "remove";
display.off(type); display.off(type);
......
# Fault Logger # Fault Logger
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> 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.
## Modules to Import ## Modules to Import
``` ```js
import faultLogger from '@ohos.faultLogger' import faultLogger from '@ohos.faultLogger'
``` ```
...@@ -56,7 +56,7 @@ Obtains the fault information about the current process. This API uses a callbac ...@@ -56,7 +56,7 @@ Obtains the fault information about the current process. This API uses a callbac
**Example** **Example**
``` ```js
function queryFaultLogCallback(error, value) { function queryFaultLogCallback(error, value) {
if (error) { if (error) {
console.info('error is ' + error); console.info('error is ' + error);
...@@ -101,7 +101,7 @@ Obtains the fault information about the current process. This API uses a promise ...@@ -101,7 +101,7 @@ Obtains the fault information about the current process. This API uses a promise
**Example** **Example**
``` ```js
async function getLog() { async function getLog() {
let value = await faultLogger.querySelfFaultLog(faultLogger.FaultType.JS_CRASH); let value = await faultLogger.querySelfFaultLog(faultLogger.FaultType.JS_CRASH);
if (value) { if (value) {
......
# HiDebug # HiDebug
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> 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.
You can run the hidebug command to obtain the memory usage of an application, including the static heap memory (native heap) and proportional set size (PSS) occupied by the application process. You can also export VM memory slices and collect VM CPU profiling data. You can run the hidebug command to obtain the memory usage of an application, including the static heap memory (native heap) and proportional set size (PSS) occupied by the application process. You can also export VM memory slices and collect VM CPU profiling data.
...@@ -20,7 +20,7 @@ Obtains the total size of the native heap memory. ...@@ -20,7 +20,7 @@ Obtains the total size of the native heap memory.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ------ | --------------------------- | | ------ | --------------------------- |
...@@ -42,7 +42,7 @@ Obtains the size of the allocated native heap memory. ...@@ -42,7 +42,7 @@ Obtains the size of the allocated native heap memory.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ------ | --------------------------------- | | ------ | --------------------------------- |
| bigint | Size of the allocated native heap memory.| | bigint | Size of the allocated native heap memory.|
...@@ -63,7 +63,7 @@ Obtains the size of the free native heap memory. ...@@ -63,7 +63,7 @@ Obtains the size of the free native heap memory.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ------ | ------------------------------- | | ------ | ------------------------------- |
| bigint | Size of the free native heap memory.| | bigint | Size of the free native heap memory.|
...@@ -84,7 +84,7 @@ Obtains the PSS of this process. ...@@ -84,7 +84,7 @@ Obtains the PSS of this process.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ------ | ------------------------- | | ------ | ------------------------- |
| bigint | PSS of the process.| | bigint | PSS of the process.|
...@@ -105,7 +105,7 @@ Obtains the size of the shared dirty memory of this process. ...@@ -105,7 +105,7 @@ Obtains the size of the shared dirty memory of this process.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------------------------- | | ------ | -------------------------- |
| bigint | Size of the shared dirty memory of the process.| | bigint | Size of the shared dirty memory of the process.|
...@@ -116,6 +116,47 @@ Obtains the size of the shared dirty memory of this process. ...@@ -116,6 +116,47 @@ Obtains the size of the shared dirty memory of this process.
let sharedDirty = hidebug.getSharedDirty(); let sharedDirty = hidebug.getSharedDirty();
``` ```
## hidebug.getPrivateDirty<sup>9+<sup>
getPrivateDirty(): bigint
Obtains the size of the private dirty memory of this process.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return value**
| Type | Description |
| ------ | -------------------------- |
| bigint | Size of the private dirty memory of the process.|
**Example**
```js
let privateDirty = hidebug.getPrivateDirty();
```
## hidebug.getCpuUsage<sup>9+<sup>
getCpuUsage(): number
Obtains the CPU usage of this process.
For example, if the CPU usage is **50%**, **0.5** is returned.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return value**
| Type | Description |
| ------ | -------------------------- |
| number | CPU usage of the process.|
**Example**
```js
let cpuUsage = hidebug.getCpuUsage();
```
## hidebug.startProfiling ## hidebug.startProfiling
...@@ -135,9 +176,9 @@ Starts the profiling method. `startProfiling()` and `stopProfiling()` are called ...@@ -135,9 +176,9 @@ Starts the profiling method. `startProfiling()` and `stopProfiling()` are called
```js ```js
hidebug.startProfiling("cpuprofiler-20220216"); hidebug.startProfiling("cpuprofiler-20220216");
// Code block // code block
// ... // ...
// Code block // code block
hidebug.stopProfiling(); hidebug.stopProfiling();
``` ```
...@@ -147,7 +188,7 @@ hidebug.stopProfiling(); ...@@ -147,7 +188,7 @@ hidebug.stopProfiling();
stopProfiling() : void stopProfiling() : void
Stops the profiling method. `stopProfiling()` and `startProfiling()` are called in pairs. `stopProfiling()` always occurs after `startProfiling()`; that is, calling the functions in the following sequences is prohibited: `start->start->stop`, `start->stop->stop`, and `start->start->stop->stop`. Stops the profiling method. `startProfiling()` and `stopProfiling()` are called in pairs. `startProfiling()` always occurs before `stopProfiling()`; that is, calling the functions in the following sequences is prohibited: `start->start->stop`, `start->stop->stop`, and `start->start->stop->stop`.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
...@@ -155,9 +196,9 @@ Stops the profiling method. `stopProfiling()` and `startProfiling()` are called ...@@ -155,9 +196,9 @@ Stops the profiling method. `stopProfiling()` and `startProfiling()` are called
```js ```js
hidebug.startProfiling("cpuprofiler-20220216"); hidebug.startProfiling("cpuprofiler-20220216");
// Code block // code block
// ... // ...
// Code block // code block
hidebug.stopProfiling(); hidebug.stopProfiling();
``` ```
...@@ -165,13 +206,13 @@ hidebug.stopProfiling(); ...@@ -165,13 +206,13 @@ hidebug.stopProfiling();
dumpHeapData(filename : string) : void dumpHeapData(filename : string) : void
Exports the heap data. Exports data from the specified heap file.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ------------------------------------------------------------ | | -------- | ------ | ---- | ------------------------------------------------------------ |
| filename | string | Yes | User-defined heap file name. The `filename.heapsnapshot` file is generated in the `files` directory of the app based on the specified `filename`.| | filename | string | Yes | User-defined heap file name. The `filename.heapsnapshot` file is generated in the `files` directory of the app based on the specified `filename`.|
...@@ -180,3 +221,31 @@ Exports the heap data. ...@@ -180,3 +221,31 @@ Exports the heap data.
```js ```js
hidebug.dumpHeapData("heap-20220216"); hidebug.dumpHeapData("heap-20220216");
``` ```
## hidebug.getServiceDump<sup>9+<sup>
getServiceDump(serviceid : number) : string
Obtains information on the specified system service.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| serviceid | number | Yes | ID of the system service. |
**Return value**
| Type | Description |
| ------ | -------------------------- |
| string | Absolute path of the file that contains the service information to dump. |
**Example**
```js
let serviceId = 10;
let pathName = hidebug.getServiceDump(serviceId);
```
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
## Modules to Import ## Modules to Import
``` ```js
import http from '@ohos.net.http'; import http from '@ohos.net.http';
``` ```
## Example ## Example
``` ```js
import http from '@ohos.net.http'; import http from '@ohos.net.http';
// Each HttpRequest corresponds to an HttpRequestTask object and cannot be reused. // Each HttpRequest corresponds to an HttpRequestTask object and cannot be reused.
...@@ -71,7 +71,7 @@ Creates an HTTP request. You can use this API to initiate or destroy an HTTP req ...@@ -71,7 +71,7 @@ Creates an HTTP request. You can use this API to initiate or destroy an HTTP req
**Example** **Example**
``` ```js
import http from '@ohos.net.http'; import http from '@ohos.net.http';
let httpRequest = http.createHttp(); let httpRequest = http.createHttp();
``` ```
...@@ -100,7 +100,7 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback ...@@ -100,7 +100,7 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback
**Example** **Example**
``` ```js
httpRequest.request("EXAMPLE_URL", (err, data) => { httpRequest.request("EXAMPLE_URL", (err, data) => {
if (!err) { if (!err) {
console.info('Result:' + data.result); console.info('Result:' + data.result);
...@@ -133,7 +133,7 @@ Initiates an HTTP request containing specified options to a given URL. This API ...@@ -133,7 +133,7 @@ Initiates an HTTP request containing specified options to a given URL. This API
**Example** **Example**
``` ```js
httpRequest.request("EXAMPLE_URL", httpRequest.request("EXAMPLE_URL",
{ {
method: http.RequestMethod.GET, method: http.RequestMethod.GET,
...@@ -183,7 +183,7 @@ Initiates an HTTP request to a given URL. This API uses a promise to return the ...@@ -183,7 +183,7 @@ Initiates an HTTP request to a given URL. This API uses a promise to return the
**Example** **Example**
``` ```js
let promise = httpRequest.request("EXAMPLE_URL", { let promise = httpRequest.request("EXAMPLE_URL", {
method: http.RequestMethod.GET, method: http.RequestMethod.GET,
connectTimeout: 60000, connectTimeout: 60000,
...@@ -214,7 +214,7 @@ Destroys an HTTP request. ...@@ -214,7 +214,7 @@ Destroys an HTTP request.
**Example** **Example**
``` ```js
httpRequest.destroy(); httpRequest.destroy();
``` ```
...@@ -239,7 +239,7 @@ Registers an observer for HTTP Response Header events. ...@@ -239,7 +239,7 @@ Registers an observer for HTTP Response Header events.
**Example** **Example**
``` ```js
httpRequest.on('headerReceive', (err, data) => { httpRequest.on('headerReceive', (err, data) => {
if (!err) { if (!err) {
console.info('header: ' + JSON.stringify(data)); console.info('header: ' + JSON.stringify(data));
...@@ -273,7 +273,7 @@ Unregisters the observer for HTTP Response Header events. ...@@ -273,7 +273,7 @@ Unregisters the observer for HTTP Response Header events.
**Example** **Example**
``` ```js
httpRequest.off('headerReceive'); httpRequest.off('headerReceive');
``` ```
...@@ -294,7 +294,7 @@ Registers an observer for HTTP Response Header events. ...@@ -294,7 +294,7 @@ Registers an observer for HTTP Response Header events.
**Example** **Example**
``` ```js
httpRequest.on('headersReceive', (header) => { httpRequest.on('headersReceive', (header) => {
console.info('header: ' + JSON.stringify(header)); console.info('header: ' + JSON.stringify(header));
}); });
...@@ -322,7 +322,7 @@ Unregisters the observer for HTTP Response Header events. ...@@ -322,7 +322,7 @@ Unregisters the observer for HTTP Response Header events.
**Example** **Example**
``` ```js
httpRequest.off('headersReceive'); httpRequest.off('headersReceive');
``` ```
...@@ -343,7 +343,7 @@ Registers a one-time observer for HTTP Response Header events. Once triggered, t ...@@ -343,7 +343,7 @@ Registers a one-time observer for HTTP Response Header events. Once triggered, t
**Example** **Example**
``` ```js
httpRequest.once('headersReceive', (header) => { httpRequest.once('headersReceive', (header) => {
console.info('header: ' + JSON.stringify(header)); console.info('header: ' + JSON.stringify(header));
}); });
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
## Modules to Import ## Modules to Import
```javascript ```js
import connection from '@ohos.net.connection' import connection from '@ohos.net.connection'
``` ```
...@@ -29,7 +29,7 @@ Obtains the default active data network. This API uses an asynchronous callback ...@@ -29,7 +29,7 @@ Obtains the default active data network. This API uses an asynchronous callback
**Example** **Example**
```javascript ```js
connection.getDefaultNet(function (error, netHandle) { connection.getDefaultNet(function (error, netHandle) {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
console.log(JSON.stringify(netHandle)) console.log(JSON.stringify(netHandle))
...@@ -54,7 +54,7 @@ Obtains the default active data network. This API uses a promise to return the r ...@@ -54,7 +54,7 @@ Obtains the default active data network. This API uses a promise to return the r
**Example** **Example**
```javascript ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
console.log(JSON.stringify(netHandle)) console.log(JSON.stringify(netHandle))
}) })
...@@ -76,7 +76,7 @@ Checks whether the default data network is activated. This API uses an asynchron ...@@ -76,7 +76,7 @@ Checks whether the default data network is activated. This API uses an asynchron
**Example** **Example**
```javascript ```js
connection.hasDefaultNet(function (error, has) { connection.hasDefaultNet(function (error, has) {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
console.log(has) console.log(has)
...@@ -99,7 +99,7 @@ Checks whether the default data network is activated. This API uses a promise to ...@@ -99,7 +99,7 @@ Checks whether the default data network is activated. This API uses a promise to
**Example** **Example**
```javascript ```js
connection.hasDefaultNet().then(function (has) { connection.hasDefaultNet().then(function (has) {
console.log(has) console.log(has)
}) })
...@@ -122,7 +122,7 @@ Obtains the list of all active data networks. This API uses an asynchronous call ...@@ -122,7 +122,7 @@ Obtains the list of all active data networks. This API uses an asynchronous call
**Example** **Example**
``` ```js
connection.getAllNets(function (error, nets) { connection.getAllNets(function (error, nets) {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
console.log(JSON.stringify(nets)) console.log(JSON.stringify(nets))
...@@ -147,7 +147,7 @@ Obtains the list of all active data networks. This API uses a promise to return ...@@ -147,7 +147,7 @@ Obtains the list of all active data networks. This API uses a promise to return
**Example** **Example**
``` ```js
connection.getAllNets().then(function (nets) { connection.getAllNets().then(function (nets) {
console.log(JSON.stringify(nets)) console.log(JSON.stringify(nets))
}); });
...@@ -172,7 +172,7 @@ Obtains connection properties of the network corresponding to given network hand ...@@ -172,7 +172,7 @@ Obtains connection properties of the network corresponding to given network hand
**Example** **Example**
```javascript ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
connection.getConnectionProperties(netHandle, function (error, info) { connection.getConnectionProperties(netHandle, function (error, info) {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
...@@ -205,7 +205,7 @@ Obtains connection properties of the network corresponding to **netHandle**. Thi ...@@ -205,7 +205,7 @@ Obtains connection properties of the network corresponding to **netHandle**. Thi
**Example** **Example**
```javascript ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
connection.getConnectionProperties(netHandle).then(function (info) { connection.getConnectionProperties(netHandle).then(function (info) {
console.log(JSON.stringify(info)) console.log(JSON.stringify(info))
...@@ -232,7 +232,7 @@ Obtains capability information of the network corresponding to **netHandle**. Th ...@@ -232,7 +232,7 @@ Obtains capability information of the network corresponding to **netHandle**. Th
**Example** **Example**
```javascript ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
connection.getNetCapabilities(netHandle, function (error, info) { connection.getNetCapabilities(netHandle, function (error, info) {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
...@@ -265,7 +265,7 @@ Obtains capability information of the network corresponding to **netHandle**. Th ...@@ -265,7 +265,7 @@ Obtains capability information of the network corresponding to **netHandle**. Th
**Example** **Example**
```javascript ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
connection.getNetCapabilities(netHandle).then(function (info) { connection.getNetCapabilities(netHandle).then(function (info) {
console.log(JSON.stringify(info)) console.log(JSON.stringify(info))
...@@ -291,7 +291,7 @@ Reports connection of the data network. This API uses an asynchronous callback t ...@@ -291,7 +291,7 @@ Reports connection of the data network. This API uses an asynchronous callback t
**Example** **Example**
``` ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
connection.reportNetConnected(netHandle, function (error) { connection.reportNetConnected(netHandle, function (error) {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
...@@ -322,7 +322,7 @@ Reports connection of the data network. This API uses a promise to return the re ...@@ -322,7 +322,7 @@ Reports connection of the data network. This API uses a promise to return the re
**Example** **Example**
``` ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
connection.reportNetConnected(netHandle).then(function () { connection.reportNetConnected(netHandle).then(function () {
console.log(`report success`) console.log(`report success`)
...@@ -349,7 +349,7 @@ Reports disconnection of the data network. This API uses an asynchronous callbac ...@@ -349,7 +349,7 @@ Reports disconnection of the data network. This API uses an asynchronous callbac
**Example** **Example**
``` ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
connection.reportNetDisconnected(netHandle, function (error) { connection.reportNetDisconnected(netHandle, function (error) {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
...@@ -380,7 +380,7 @@ Reports disconnection of the data network. This API uses a promise to return the ...@@ -380,7 +380,7 @@ Reports disconnection of the data network. This API uses a promise to return the
**Example** **Example**
``` ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
connection.reportNetDisconnected(netHandle).then(function () { connection.reportNetDisconnected(netHandle).then(function () {
console.log(`report success`) console.log(`report success`)
...@@ -407,7 +407,7 @@ Resolves the host name by using the default network to obtain all IP addresses. ...@@ -407,7 +407,7 @@ Resolves the host name by using the default network to obtain all IP addresses.
**Example** **Example**
``` ```js
let host = "xxxx"; let host = "xxxx";
connection.getAddressesByName(host, function (error, addresses) { connection.getAddressesByName(host, function (error, addresses) {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
...@@ -439,7 +439,7 @@ Resolves the host name by using the default network to obtain all IP addresses. ...@@ -439,7 +439,7 @@ Resolves the host name by using the default network to obtain all IP addresses.
**Example** **Example**
``` ```js
let host = "xxxx"; let host = "xxxx";
connection.getAddressesByName(host).then(function (addresses) { connection.getAddressesByName(host).then(function (addresses) {
console.log(JSON.stringify(addresses)) console.log(JSON.stringify(addresses))
...@@ -469,7 +469,7 @@ Obtains the handle of the network specified by **netSpecifier**. ...@@ -469,7 +469,7 @@ Obtains the handle of the network specified by **netSpecifier**.
**Example** **Example**
```javascript ```js
// Default network // Default network
let netConnection = connection.createNetConnection() let netConnection = connection.createNetConnection()
...@@ -502,7 +502,7 @@ Registers a listener for **netAvailable** events. ...@@ -502,7 +502,7 @@ Registers a listener for **netAvailable** events.
**Example** **Example**
```javascript ```js
netConnection.on('netAvailable', function (data) { netConnection.on('netAvailable', function (data) {
console.log(JSON.stringify(data)) console.log(JSON.stringify(data))
}) })
...@@ -525,7 +525,7 @@ Registers a listener for **netCapabilitiesChange** events. ...@@ -525,7 +525,7 @@ Registers a listener for **netCapabilitiesChange** events.
**Example** **Example**
```javascript ```js
netConnection.on('netCapabilitiesChange', function (data) { netConnection.on('netCapabilitiesChange', function (data) {
console.log(JSON.stringify(data)) console.log(JSON.stringify(data))
}) })
...@@ -548,7 +548,7 @@ Registers a listener for **netConnectionPropertiesChange** events. ...@@ -548,7 +548,7 @@ Registers a listener for **netConnectionPropertiesChange** events.
**Example** **Example**
```javascript ```js
netConnection.on('netConnectionPropertiesChange', function (data) { netConnection.on('netConnectionPropertiesChange', function (data) {
console.log(JSON.stringify(data)) console.log(JSON.stringify(data))
}) })
...@@ -571,7 +571,7 @@ Registers a listener for **netBlockStatusChange** events. ...@@ -571,7 +571,7 @@ Registers a listener for **netBlockStatusChange** events.
**Example** **Example**
```javascript ```js
netConnection.on('netBlockStatusChange', function (data) { netConnection.on('netBlockStatusChange', function (data) {
console.log(JSON.stringify(data)) console.log(JSON.stringify(data))
}) })
...@@ -594,7 +594,7 @@ Registers a listener for **netLost** events. ...@@ -594,7 +594,7 @@ Registers a listener for **netLost** events.
**Example** **Example**
```javascript ```js
let netConnection1 = connection.createNetConnection() let netConnection1 = connection.createNetConnection()
netConnection1.on('netLost', function (data) { netConnection1.on('netLost', function (data) {
console.log(JSON.stringify(data)) console.log(JSON.stringify(data))
...@@ -618,7 +618,7 @@ Registers a listener for **netUnavailable** events. ...@@ -618,7 +618,7 @@ Registers a listener for **netUnavailable** events.
**Example** **Example**
```javascript ```js
netConnection.on('netUnavailable', function (data) { netConnection.on('netUnavailable', function (data) {
console.log(JSON.stringify(data)) console.log(JSON.stringify(data))
}) })
...@@ -642,7 +642,7 @@ Registers a listener for network status changes. ...@@ -642,7 +642,7 @@ Registers a listener for network status changes.
**Example** **Example**
```javascript ```js
netConnection.register(function (error) { netConnection.register(function (error) {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
}) })
...@@ -664,7 +664,7 @@ Unregisters the listener for network status changes. ...@@ -664,7 +664,7 @@ Unregisters the listener for network status changes.
**Example** **Example**
```javascript ```js
netConnection.unregister(function (error) { netConnection.unregister(function (error) {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
}) })
...@@ -703,7 +703,7 @@ Resolves the host name by using the corresponding network to obtain all IP addre ...@@ -703,7 +703,7 @@ Resolves the host name by using the corresponding network to obtain all IP addre
**Example** **Example**
```javascript ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
let host = "xxxx"; let host = "xxxx";
netHandle.getAddressesByName(host, function (error, addresses) { netHandle.getAddressesByName(host, function (error, addresses) {
...@@ -737,7 +737,7 @@ Resolves the host name by using the corresponding network to obtain all IP addre ...@@ -737,7 +737,7 @@ Resolves the host name by using the corresponding network to obtain all IP addre
**Example** **Example**
```javascript ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
let host = "xxxx"; let host = "xxxx";
netHandle.getAddressesByName(host).then(function (addresses) { netHandle.getAddressesByName(host).then(function (addresses) {
...@@ -765,7 +765,7 @@ Resolves the host name by using the corresponding network to obtain the first IP ...@@ -765,7 +765,7 @@ Resolves the host name by using the corresponding network to obtain the first IP
**Example** **Example**
```javascript ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
let host = "xxxx"; let host = "xxxx";
netHandle.getAddressByName(host, function (error, address) { netHandle.getAddressByName(host, function (error, address) {
...@@ -799,7 +799,7 @@ Resolves the host name by using the corresponding network to obtain the first IP ...@@ -799,7 +799,7 @@ Resolves the host name by using the corresponding network to obtain the first IP
**Example** **Example**
```javascript ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
let host = "xxxx"; let host = "xxxx";
netHandle.getAddressByName(host).then(function (address) { netHandle.getAddressByName(host).then(function (address) {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
## Modules to Import ## Modules to Import
``` ```js
import observer from '@ohos.telephony.observer' import observer from '@ohos.telephony.observer'
``` ```
...@@ -30,7 +30,7 @@ Registers an observer for network status change events. This API uses an asynchr ...@@ -30,7 +30,7 @@ Registers an observer for network status change events. This API uses an asynchr
**Example** **Example**
``` ```js
observer.on('networkStateChange', data =>{ observer.on('networkStateChange', data =>{
console.log("on networkStateChange, data:" + JSON.stringify(data)); console.log("on networkStateChange, data:" + JSON.stringify(data));
}); });
...@@ -57,7 +57,7 @@ Registers an observer for network status change events of the SIM card in the sp ...@@ -57,7 +57,7 @@ Registers an observer for network status change events of the SIM card in the sp
**Example** **Example**
``` ```js
observer.on('networkStateChange', {slotId: 0}, data =>{ observer.on('networkStateChange', {slotId: 0}, data =>{
console.log("on networkStateChange, data:" + JSON.stringify(data)); console.log("on networkStateChange, data:" + JSON.stringify(data));
}); });
...@@ -87,7 +87,7 @@ Unregisters the observer for network status change events. This API uses an asyn ...@@ -87,7 +87,7 @@ Unregisters the observer for network status change events. This API uses an asyn
**Example** **Example**
``` ```js
let callback = data => { let callback = data => {
console.log("on networkStateChange, data:" + JSON.stringify(data)); console.log("on networkStateChange, data:" + JSON.stringify(data));
} }
...@@ -114,7 +114,7 @@ Registers an observer for signal status change events. This API uses an asynchro ...@@ -114,7 +114,7 @@ Registers an observer for signal status change events. This API uses an asynchro
**Example** **Example**
``` ```js
observer.on('signalInfoChange', data =>{ observer.on('signalInfoChange', data =>{
console.log("on signalInfoChange, data:" + JSON.stringify(data)); console.log("on signalInfoChange, data:" + JSON.stringify(data));
}); });
...@@ -139,7 +139,7 @@ Registers an observer for signal status change events of the SIM card in the spe ...@@ -139,7 +139,7 @@ Registers an observer for signal status change events of the SIM card in the spe
**Example** **Example**
``` ```js
observer.on('signalInfoChange', {slotId: 0}, data =>{ observer.on('signalInfoChange', {slotId: 0}, data =>{
console.log("on signalInfoChange, data:" + JSON.stringify(data)); console.log("on signalInfoChange, data:" + JSON.stringify(data));
}); });
...@@ -167,7 +167,7 @@ Unregisters the observer for signal status change events. This API uses an async ...@@ -167,7 +167,7 @@ Unregisters the observer for signal status change events. This API uses an async
**Example** **Example**
``` ```js
let callback = data => { let callback = data => {
console.log("on signalInfoChange, data:" + JSON.stringify(data)); console.log("on signalInfoChange, data:" + JSON.stringify(data));
} }
...@@ -197,7 +197,7 @@ Registers an observer for call status change events. This API uses an asynchrono ...@@ -197,7 +197,7 @@ Registers an observer for call status change events. This API uses an asynchrono
**Example** **Example**
``` ```js
observer.on('callStateChange', value =>{ observer.on('callStateChange', value =>{
console.log("on callStateChange, state:" + value.state + ", number:" + value.number); console.log("on callStateChange, state:" + value.state + ", number:" + value.number);
}); });
...@@ -224,7 +224,7 @@ Registers an observer for call status change events. This API uses an asynchrono ...@@ -224,7 +224,7 @@ Registers an observer for call status change events. This API uses an asynchrono
**Example** **Example**
``` ```js
observer.on('callStateChange', {slotId: 0}, value =>{ observer.on('callStateChange', {slotId: 0}, value =>{
console.log("on callStateChange, state:" + value.state + ", number:" + value.number); console.log("on callStateChange, state:" + value.state + ", number:" + value.number);
}); });
...@@ -254,7 +254,7 @@ Unregisters the observer for call status change events. This API uses an asynchr ...@@ -254,7 +254,7 @@ Unregisters the observer for call status change events. This API uses an asynchr
**Example** **Example**
``` ```js
let callback = value => { let callback = value => {
console.log("on callStateChange, state:" + value.state + ", number:" + value.number); console.log("on callStateChange, state:" + value.state + ", number:" + value.number);
} }
...@@ -282,7 +282,7 @@ Registers an observer for connection status change events of the cellular data l ...@@ -282,7 +282,7 @@ Registers an observer for connection status change events of the cellular data l
**Example** **Example**
``` ```js
observer.on('cellularDataConnectionStateChange', value =>{ observer.on('cellularDataConnectionStateChange', value =>{
console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network); console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network);
}); });
...@@ -307,7 +307,7 @@ Registers an observer for connection status change events of the cellular data l ...@@ -307,7 +307,7 @@ Registers an observer for connection status change events of the cellular data l
**Example** **Example**
``` ```js
observer.on('cellularDataConnectionStateChange', {slotId: 0}, value =>{ observer.on('cellularDataConnectionStateChange', {slotId: 0}, value =>{
console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network); console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network);
}); });
...@@ -335,7 +335,7 @@ Unregisters the observer for connection status change events of the cellular dat ...@@ -335,7 +335,7 @@ Unregisters the observer for connection status change events of the cellular dat
**Example** **Example**
``` ```js
let callback = value => { let callback = value => {
console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network); console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network);
} }
...@@ -363,7 +363,7 @@ Registers an observer for the uplink and downlink data flow status change events ...@@ -363,7 +363,7 @@ Registers an observer for the uplink and downlink data flow status change events
**Example** **Example**
``` ```js
observer.on('cellularDataFlowChange', data =>{ observer.on('cellularDataFlowChange', data =>{
console.log("on networkStateChange, data:" + JSON.stringify(data)); console.log("on networkStateChange, data:" + JSON.stringify(data));
}); });
...@@ -388,7 +388,7 @@ Registers an observer for the uplink and downlink data flow status change events ...@@ -388,7 +388,7 @@ Registers an observer for the uplink and downlink data flow status change events
**Example** **Example**
``` ```js
observer.on('cellularDataFlowChange', {slotId: 0}, data =>{ observer.on('cellularDataFlowChange', {slotId: 0}, data =>{
console.log("on cellularDataFlowChange, data:" + JSON.stringify(data)); console.log("on cellularDataFlowChange, data:" + JSON.stringify(data));
}); });
...@@ -416,7 +416,7 @@ Unregisters the observer for the uplink and downlink data flow status change eve ...@@ -416,7 +416,7 @@ Unregisters the observer for the uplink and downlink data flow status change eve
**Example** **Example**
``` ```js
let callback = data => { let callback = data => {
console.log("on cellularDataFlowChange, data:" + JSON.stringify(data)); console.log("on cellularDataFlowChange, data:" + JSON.stringify(data));
} }
...@@ -444,7 +444,7 @@ Registers an observer for SIM card status change events. This API uses an asynch ...@@ -444,7 +444,7 @@ Registers an observer for SIM card status change events. This API uses an asynch
**Example** **Example**
``` ```js
observer.on('simStateChange', data =>{ observer.on('simStateChange', data =>{
console.log("on simStateChange, data:" + JSON.stringify(data)); console.log("on simStateChange, data:" + JSON.stringify(data));
}); });
...@@ -469,7 +469,7 @@ Registers an observer for status change events of the SIM card in the specified ...@@ -469,7 +469,7 @@ Registers an observer for status change events of the SIM card in the specified
**Example** **Example**
``` ```js
observer.on('simStateChange', {slotId: 0}, data =>{ observer.on('simStateChange', {slotId: 0}, data =>{
console.log("on simStateChange, data:" + JSON.stringify(data)); console.log("on simStateChange, data:" + JSON.stringify(data));
}); });
...@@ -497,7 +497,7 @@ Unregisters the observer for SIM card status change events. This API uses an asy ...@@ -497,7 +497,7 @@ Unregisters the observer for SIM card status change events. This API uses an asy
**Example** **Example**
``` ```js
let callback = data => { let callback = data => {
console.log("on simStateChange, data:" + JSON.stringify(data)); console.log("on simStateChange, data:" + JSON.stringify(data));
} }
......
...@@ -17,13 +17,13 @@ import process from '@ohos.process'; ...@@ -17,13 +17,13 @@ import process from '@ohos.process';
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| egid | number | Yes| No| Effective group identifier (EGID) of a process.| | egid | number | Yes| No| Effective group identifier (EGID) of a process. This is a system API and cannot be called by third-party applications.|
| euid | number | Yes| No| Effective user identifier (EUID) of a process.| | euid | number | Yes| No| Effective user identifier (EUID) of a process. This is a system API and cannot be called by third-party applications.|
| gid | number | Yes| No| Group identifier (GID) of a process.| | gid | number | Yes| No| Group identifier (GID) of a process. This is a system API and cannot be called by third-party applications.|
| uid | number | Yes| No| User identifier (UID) of a process.| | uid | number | Yes| No| User identifier (UID) of a process.|
| groups | number[] | Yes| No| Array with supplementary group IDs.| | groups | number[] | Yes| No| Array with supplementary group IDs. This is a system API and cannot be called by third-party applications.|
| pid | number | Yes| No| Process ID (PID) of a process.| | pid | number | Yes| No| Process ID (PID) of a process.|
| ppid | number | Yes| No| Parent process ID (PPID) of a process.| | ppid | number | Yes| No| Parent process ID (PPID) of a process. This is a system API and cannot be called by third-party applications.|
| tid<sup>8+</sup> | number | Yes| No| Thread ID (TID) of a process.| | tid<sup>8+</sup> | number | Yes| No| Thread ID (TID) of a process.|
...@@ -38,10 +38,10 @@ Allows a process to obtain the standard input and output of its child processes, ...@@ -38,10 +38,10 @@ Allows a process to obtain the standard input and output of its child processes,
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| pid | number | Yes| No| PID of the child process.| | pid | number | Yes| No| PID of the child process. This is a system API and cannot be called by third-party applications.|
| ppid | number | Yes| No| PPID of the child process.| | ppid | number | Yes| No| PPID of the child process. This is a system API and cannot be called by third-party applications.|
| exitCode | number | Yes| No| Exit code of the child process.| | exitCode | number | Yes| No| Exit code of the child process. This is a system API and cannot be called by third-party applications.|
| killed | boolean | Yes| No| Whether the parent process successfully sends a signal to the child process to terminate it.| | killed | boolean | Yes| No| Whether the parent process successfully sends a signal to the child process to terminate it. This is a system API and cannot be called by third-party applications.|
### wait ### wait
...@@ -50,6 +50,8 @@ wait(): Promise&lt;number&gt; ...@@ -50,6 +50,8 @@ wait(): Promise&lt;number&gt;
Waits until the child process ends. This method uses a promise to return the exit code of the child process. Waits until the child process ends. This method uses a promise to return the exit code of the child process.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
...@@ -75,6 +77,8 @@ getOutput(): Promise&lt;Uint8Array&gt; ...@@ -75,6 +77,8 @@ getOutput(): Promise&lt;Uint8Array&gt;
Obtains the standard output of the child process. Obtains the standard output of the child process.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
...@@ -100,6 +104,8 @@ getErrorOutput(): Promise&lt;Uint8Array&gt; ...@@ -100,6 +104,8 @@ getErrorOutput(): Promise&lt;Uint8Array&gt;
Obtains the standard error output of the child process. Obtains the standard error output of the child process.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
...@@ -125,6 +131,8 @@ close(): void ...@@ -125,6 +131,8 @@ close(): void
Closes the child process in running. Closes the child process in running.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Example** **Example**
...@@ -141,6 +149,8 @@ kill(signal: number | string): void ...@@ -141,6 +149,8 @@ kill(signal: number | string): void
Sends a signal to the specified child process to terminate it. Sends a signal to the specified child process to terminate it.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -383,6 +393,8 @@ runCmd(command: string, options?: { timeout : number, killSignal : number | stri ...@@ -383,6 +393,8 @@ runCmd(command: string, options?: { timeout : number, killSignal : number | stri
Forks a new process to run a shell command and returns the **ChildProcess** object. Forks a new process to run a shell command and returns the **ChildProcess** object.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -438,6 +450,8 @@ on(type: string, listener: EventListener): void ...@@ -438,6 +450,8 @@ on(type: string, listener: EventListener): void
Stores the events triggered by the user. Stores the events triggered by the user.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -468,6 +482,8 @@ off(type: string): boolean ...@@ -468,6 +482,8 @@ off(type: string): boolean
Deletes the event stored by the user. Deletes the event stored by the user.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -521,6 +537,8 @@ cwd(): string ...@@ -521,6 +537,8 @@ cwd(): string
Obtains the working directory of this process. Obtains the working directory of this process.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Example** **Example**
...@@ -536,6 +554,8 @@ chdir(dir: string): void ...@@ -536,6 +554,8 @@ chdir(dir: string): void
Changes the working directory of this process. Changes the working directory of this process.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -594,6 +614,7 @@ Sends a signal to the specified process to terminate it. ...@@ -594,6 +614,7 @@ Sends a signal to the specified process to terminate it.
| boolean | Returns **true** if the signal is sent successfully; returns **false** otherwise.| | boolean | Returns **true** if the signal is sent successfully; returns **false** otherwise.|
**Example** **Example**
```js ```js
var pres = process.pid var pres = process.pid
var result = that.kill(28, pres) var result = that.kill(28, pres)
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
## Modules to Import ## Modules to Import
``` ```js
import radio from '@ohos.telephony.radio' import radio from '@ohos.telephony.radio'
``` ```
...@@ -30,7 +30,7 @@ Obtains the radio access technology (RAT) used by the CS and PS domains. This AP ...@@ -30,7 +30,7 @@ Obtains the radio access technology (RAT) used by the CS and PS domains. This AP
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
radio.getRadioTech(slotId, (err, data) =>{ radio.getRadioTech(slotId, (err, data) =>{
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
...@@ -62,7 +62,7 @@ Obtains the RAT used by the CS and PS domains. This API uses a promise to return ...@@ -62,7 +62,7 @@ Obtains the RAT used by the CS and PS domains. This API uses a promise to return
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
let promise = radio.getRadioTech(slotId); let promise = radio.getRadioTech(slotId);
promise.then(data => { promise.then(data => {
...@@ -91,7 +91,7 @@ Obtains the network status. This API uses an asynchronous callback to return the ...@@ -91,7 +91,7 @@ Obtains the network status. This API uses an asynchronous callback to return the
**Example** **Example**
``` ```js
radio.getNetworkState((err, data) =>{ radio.getNetworkState((err, data) =>{
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -117,7 +117,7 @@ Obtains the network status. This API uses an asynchronous callback to return the ...@@ -117,7 +117,7 @@ Obtains the network status. This API uses an asynchronous callback to return the
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
radio.getNetworkState(slotId, (err, data) => { radio.getNetworkState(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
...@@ -149,7 +149,7 @@ Obtains the network status of the SIM card in the specified slot. This API uses ...@@ -149,7 +149,7 @@ Obtains the network status of the SIM card in the specified slot. This API uses
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
let promise = radio.getNetworkState(slotId); let promise = radio.getNetworkState(slotId);
promise.then(data => { promise.then(data => {
...@@ -177,7 +177,7 @@ Obtains the network selection mode of the SIM card in the specified slot. This A ...@@ -177,7 +177,7 @@ Obtains the network selection mode of the SIM card in the specified slot. This A
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
radio.getNetworkSelectionMode(slotId, (err, data) => { radio.getNetworkSelectionMode(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
...@@ -207,7 +207,7 @@ Obtains the network selection mode of the SIM card in the specified slot. This A ...@@ -207,7 +207,7 @@ Obtains the network selection mode of the SIM card in the specified slot. This A
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
let promise = radio.getNetworkSelectionMode(slotId); let promise = radio.getNetworkSelectionMode(slotId);
promise.then(data => { promise.then(data => {
...@@ -235,7 +235,7 @@ Obtains the ISO country code of the network with which the SIM card in the speci ...@@ -235,7 +235,7 @@ Obtains the ISO country code of the network with which the SIM card in the speci
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
radio.getISOCountryCodeForNetwork(slotId, (err, data) => { radio.getISOCountryCodeForNetwork(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
...@@ -265,7 +265,7 @@ Obtains the ISO country code of the network with which the SIM card in the speci ...@@ -265,7 +265,7 @@ Obtains the ISO country code of the network with which the SIM card in the speci
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
let promise = radio.getISOCountryCodeForNetwork(slotId); let promise = radio.getISOCountryCodeForNetwork(slotId);
promise.then(data => { promise.then(data => {
...@@ -292,7 +292,7 @@ Obtains the ID of the slot in which the primary card is located. This API uses a ...@@ -292,7 +292,7 @@ Obtains the ID of the slot in which the primary card is located. This API uses a
**Example** **Example**
``` ```js
radio.getPrimarySlotId((err, data) => { radio.getPrimarySlotId((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -315,7 +315,7 @@ Obtains the ID of the slot in which the primary card is located. This API uses a ...@@ -315,7 +315,7 @@ Obtains the ID of the slot in which the primary card is located. This API uses a
**Example** **Example**
``` ```js
let promise = radio.getPrimarySlotId(); let promise = radio.getPrimarySlotId();
promise.then(data => { promise.then(data => {
console.log(`getPrimarySlotId success, promise: data->${JSON.stringify(data)}`); console.log(`getPrimarySlotId success, promise: data->${JSON.stringify(data)}`);
...@@ -342,7 +342,7 @@ Obtains a list of signal strengths of the network with which the SIM card in the ...@@ -342,7 +342,7 @@ Obtains a list of signal strengths of the network with which the SIM card in the
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
radio.getSignalInformation(slotId, (err, data) => { radio.getSignalInformation(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
...@@ -372,7 +372,7 @@ Obtains a list of signal strengths of the network with which the SIM card in the ...@@ -372,7 +372,7 @@ Obtains a list of signal strengths of the network with which the SIM card in the
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
let promise = radio.getSignalInformation(slotId); let promise = radio.getSignalInformation(slotId);
promise.then(data => { promise.then(data => {
...@@ -405,7 +405,7 @@ Checks whether the current device supports 5G \(NR\). ...@@ -405,7 +405,7 @@ Checks whether the current device supports 5G \(NR\).
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
let result = radio.isNrSupported(slotId); let result = radio.isNrSupported(slotId);
console.log(result); console.log(result);
...@@ -430,7 +430,7 @@ Checks whether the radio service is enabled on the primary SIM card. This API us ...@@ -430,7 +430,7 @@ Checks whether the radio service is enabled on the primary SIM card. This API us
**Example** **Example**
``` ```js
radio.isRadioOn((err, data) => { radio.isRadioOn((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -456,7 +456,7 @@ Checks whether the radio service is enabled on the SIM card in the specified slo ...@@ -456,7 +456,7 @@ Checks whether the radio service is enabled on the SIM card in the specified slo
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
radio.isRadioOn(slotId, (err, data) => { radio.isRadioOn(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
...@@ -488,7 +488,7 @@ Checks whether the radio service is enabled. This API uses a promise to return t ...@@ -488,7 +488,7 @@ Checks whether the radio service is enabled. This API uses a promise to return t
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
let promise = radio.isRadioOn(slotId); let promise = radio.isRadioOn(slotId);
promise.then(data => { promise.then(data => {
...@@ -516,7 +516,7 @@ Obtains the carrier name. This API uses an asynchronous callback to return the r ...@@ -516,7 +516,7 @@ Obtains the carrier name. This API uses an asynchronous callback to return the r
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
radio.getOperatorName(slotId, (err, data) => { radio.getOperatorName(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
...@@ -546,7 +546,7 @@ Obtains the carrier name. This API uses a promise to return the result. ...@@ -546,7 +546,7 @@ Obtains the carrier name. This API uses a promise to return the result.
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
let promise = radio.getOperatorName(slotId); let promise = radio.getOperatorName(slotId);
promise.then(data => { promise.then(data => {
......
# Screenshot # Screenshot
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
...@@ -58,14 +58,14 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a cal ...@@ -58,14 +58,14 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a cal
**Required permissions**: ohos.permission.CAPTURE_SCREEN **Required permissions**: ohos.permission.CAPTURE_SCREEN
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.| | options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.|
| callback | AsyncCallback&lt;image.PixelMap&gt; | Yes | Callback used to return a **PixelMap** object. | | callback | AsyncCallback&lt;image.PixelMap&gt; | Yes | Callback used to return a **PixelMap** object. |
- Example **Example**
```js ```js
var ScreenshotOptions = { var ScreenshotOptions = {
...@@ -98,19 +98,19 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a pro ...@@ -98,19 +98,19 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a pro
**Required permissions**: ohos.permission.CAPTURE_SCREEN **Required permissions**: ohos.permission.CAPTURE_SCREEN
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | --------------------------------------- | ---- | ------------------------------------------------------------ | | ------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.| | options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.|
- Return value **Return value**
| Type | Description | | Type | Description |
| ----------------------------- | ----------------------------------------------- | | ----------------------------- | ----------------------------------------------- |
| Promise&lt;image.PixelMap&gt; | Promise used to return an **image.PixelMap** object.| | Promise&lt;image.PixelMap&gt; | Promise used to return an **image.PixelMap** object.|
- Example **Example**
```js ```js
var ScreenshotOptions = { var ScreenshotOptions = {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
## Modules to Import ## Modules to Import
``` ```js
import sim from '@ohos.telephony.sim'; import sim from '@ohos.telephony.sim';
``` ```
...@@ -28,7 +28,7 @@ Checks whether the SIM card in the specified slot is activated. This API uses an ...@@ -28,7 +28,7 @@ Checks whether the SIM card in the specified slot is activated. This API uses an
**Example** **Example**
``` ```js
sim.isSimActive(0, (err, data) => { sim.isSimActive(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -57,7 +57,7 @@ Checks whether the SIM card in the specified slot is activated. This API uses a ...@@ -57,7 +57,7 @@ Checks whether the SIM card in the specified slot is activated. This API uses a
**Example** **Example**
``` ```js
let promise = sim.isSimActive(0); let promise = sim.isSimActive(0);
promise.then(data => { promise.then(data => {
console.log(`isSimActive success, promise: data->${JSON.stringify(data)}`); console.log(`isSimActive success, promise: data->${JSON.stringify(data)}`);
...@@ -83,7 +83,7 @@ Obtains the default slot ID of the SIM card that provides voice services. This A ...@@ -83,7 +83,7 @@ Obtains the default slot ID of the SIM card that provides voice services. This A
**Example** **Example**
``` ```js
sim.getDefaultVoiceSlotId((err, data) => { sim.getDefaultVoiceSlotId((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -106,7 +106,7 @@ Obtains the default slot ID of the SIM card that provides voice services. This A ...@@ -106,7 +106,7 @@ Obtains the default slot ID of the SIM card that provides voice services. This A
**Example** **Example**
``` ```js
let promise = sim.getDefaultVoiceSlotId(); let promise = sim.getDefaultVoiceSlotId();
promise.then(data => { promise.then(data => {
console.log(`getDefaultVoiceSlotId success, promise: data->${JSON.stringify(data)}`); console.log(`getDefaultVoiceSlotId success, promise: data->${JSON.stringify(data)}`);
...@@ -132,7 +132,7 @@ Checks whether the application (caller) has been granted the operator permission ...@@ -132,7 +132,7 @@ Checks whether the application (caller) has been granted the operator permission
**Example** **Example**
``` ```js
sim.hasOperatorPrivileges(0, (err, data) => { sim.hasOperatorPrivileges(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -160,7 +160,7 @@ Checks whether the application (caller) has been granted the operator permission ...@@ -160,7 +160,7 @@ Checks whether the application (caller) has been granted the operator permission
**Example** **Example**
``` ```js
let promise = sim.hasOperatorPrivileges(0); let promise = sim.hasOperatorPrivileges(0);
promise.then(data => { promise.then(data => {
console.log(`hasOperatorPrivileges success, promise: data->${JSON.stringify(data)}`); console.log(`hasOperatorPrivileges success, promise: data->${JSON.stringify(data)}`);
...@@ -186,7 +186,7 @@ Obtains the ISO country code of the SIM card in the specified slot. This API use ...@@ -186,7 +186,7 @@ Obtains the ISO country code of the SIM card in the specified slot. This API use
**Example** **Example**
``` ```js
sim.getISOCountryCodeForSim(0, (err, data) => { sim.getISOCountryCodeForSim(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -215,7 +215,7 @@ Obtains the ISO country code of the SIM card in the specified slot. This API use ...@@ -215,7 +215,7 @@ Obtains the ISO country code of the SIM card in the specified slot. This API use
**Example** **Example**
``` ```js
let promise = sim.getISOCountryCodeForSim(0); let promise = sim.getISOCountryCodeForSim(0);
promise.then(data => { promise.then(data => {
console.log(`getISOCountryCodeForSim success, promise: data->${JSON.stringify(data)}`); console.log(`getISOCountryCodeForSim success, promise: data->${JSON.stringify(data)}`);
...@@ -242,7 +242,7 @@ Obtains the public land mobile network (PLMN) ID of the SIM card in the specifie ...@@ -242,7 +242,7 @@ Obtains the public land mobile network (PLMN) ID of the SIM card in the specifie
**Example** **Example**
``` ```js
sim.getSimOperatorNumeric(0, (err, data) => { sim.getSimOperatorNumeric(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -271,7 +271,7 @@ Obtains the PLMN ID of the SIM card in the specified slot. This API uses a promi ...@@ -271,7 +271,7 @@ Obtains the PLMN ID of the SIM card in the specified slot. This API uses a promi
**Example** **Example**
``` ```js
let promise = sim.getSimOperatorNumeric(0); let promise = sim.getSimOperatorNumeric(0);
promise.then(data => { promise.then(data => {
console.log(`getSimOperatorNumeric success, promise: data->${JSON.stringify(data)}`); console.log(`getSimOperatorNumeric success, promise: data->${JSON.stringify(data)}`);
...@@ -298,7 +298,7 @@ Obtains the service provider name (SPN) of the SIM card in the specified slot. T ...@@ -298,7 +298,7 @@ Obtains the service provider name (SPN) of the SIM card in the specified slot. T
**Example** **Example**
``` ```js
sim.getSimSpn(0, (err, data) => { sim.getSimSpn(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -327,7 +327,7 @@ Obtains the SPN of the SIM card in the specified slot. This API uses a promise t ...@@ -327,7 +327,7 @@ Obtains the SPN of the SIM card in the specified slot. This API uses a promise t
**Example** **Example**
``` ```js
let promise = sim.getSimSpn(0); let promise = sim.getSimSpn(0);
promise.then(data => { promise.then(data => {
console.log(`getSimSpn success, promise: data->${JSON.stringify(data)}`); console.log(`getSimSpn success, promise: data->${JSON.stringify(data)}`);
...@@ -354,7 +354,7 @@ Obtains the status of the SIM card in the specified slot. This API uses an async ...@@ -354,7 +354,7 @@ Obtains the status of the SIM card in the specified slot. This API uses an async
**Example** **Example**
``` ```js
sim.getSimState(0, (err, data) => { sim.getSimState(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -383,7 +383,7 @@ Obtains the status of the SIM card in the specified slot. This API uses a promis ...@@ -383,7 +383,7 @@ Obtains the status of the SIM card in the specified slot. This API uses a promis
**Example** **Example**
``` ```js
let promise = sim.getSimState(0); let promise = sim.getSimState(0);
promise.then(data => { promise.then(data => {
console.log(`getSimState success, promise: data->${JSON.stringify(data)}`); console.log(`getSimState success, promise: data->${JSON.stringify(data)}`);
...@@ -409,7 +409,7 @@ Obtains the type of the SIM card in the specified slot. This API uses an asynchr ...@@ -409,7 +409,7 @@ Obtains the type of the SIM card in the specified slot. This API uses an asynchr
**Example** **Example**
``` ```js
sim.getCardType(0, (err, data) => { sim.getCardType(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -438,7 +438,7 @@ Obtains the type of the SIM card in the specified slot. This API uses a promise ...@@ -438,7 +438,7 @@ Obtains the type of the SIM card in the specified slot. This API uses a promise
**Example** **Example**
``` ```js
let promise = sim.getCardType(0); let promise = sim.getCardType(0);
promise.then(data => { promise.then(data => {
console.log(`getCardType success, promise: data->${JSON.stringify(data)}`); console.log(`getCardType success, promise: data->${JSON.stringify(data)}`);
...@@ -465,7 +465,7 @@ Checks whether the SIM card in the specified slot is installed. This API uses an ...@@ -465,7 +465,7 @@ Checks whether the SIM card in the specified slot is installed. This API uses an
**Example** **Example**
``` ```js
sim.hasSimCard(0, (err, data) => { sim.hasSimCard(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -494,7 +494,7 @@ Checks whether the SIM card in the specified slot is installed. This API uses a ...@@ -494,7 +494,7 @@ Checks whether the SIM card in the specified slot is installed. This API uses a
**Example** **Example**
``` ```js
let promise = sim.hasSimCard(0); let promise = sim.hasSimCard(0);
promise.then(data => { promise.then(data => {
console.log(`hasSimCard success, promise: data->${JSON.stringify(data)}`); console.log(`hasSimCard success, promise: data->${JSON.stringify(data)}`);
...@@ -520,7 +520,7 @@ Obtains the number of card slots. ...@@ -520,7 +520,7 @@ Obtains the number of card slots.
**Example** **Example**
``` ```js
console.log(sim.getMaxSimCount()) console.log(sim.getMaxSimCount())
``` ```
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
## Modules to Import ## Modules to Import
``` ```js
import sms from '@ohos.telephony.sms'; import sms from '@ohos.telephony.sms';
``` ```
...@@ -28,7 +28,7 @@ Creates an SMS message instance based on the protocol data unit (PDU) and the sp ...@@ -28,7 +28,7 @@ Creates an SMS message instance based on the protocol data unit (PDU) and the sp
**Example** **Example**
``` ```js
const specification = '3gpp'; const specification = '3gpp';
// Display PDUs using numbers in an array, for example, [0x08, 0x91, ...]. // Display PDUs using numbers in an array, for example, [0x08, 0x91, ...].
const pdu = [0x08, 0x91]; const pdu = [0x08, 0x91];
...@@ -61,7 +61,7 @@ Creates an SMS message instance based on the PDU and the specified SMS protocol. ...@@ -61,7 +61,7 @@ Creates an SMS message instance based on the PDU and the specified SMS protocol.
**Example** **Example**
``` ```js
const specification = '3gpp'; const specification = '3gpp';
// Display PDUs using numbers in an array, for example, [0x08, 0x91, ...]. // Display PDUs using numbers in an array, for example, [0x08, 0x91, ...].
const pdu = [0x08, 0x91]; const pdu = [0x08, 0x91];
...@@ -91,7 +91,7 @@ Sends an SMS message. ...@@ -91,7 +91,7 @@ Sends an SMS message.
**Example** **Example**
``` ```js
let sendCallback = function (err, data) { let sendCallback = function (err, data) {
console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
} }
...@@ -124,7 +124,7 @@ Obtains the default slot of the SIM card used to send SMS messages. This API use ...@@ -124,7 +124,7 @@ Obtains the default slot of the SIM card used to send SMS messages. This API use
**Example** **Example**
``` ```js
sms.getDefaultSmsSlotId((err, data) => { sms.getDefaultSmsSlotId((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -147,7 +147,7 @@ Obtains the default slot of the SIM card used to send SMS messages. This API use ...@@ -147,7 +147,7 @@ Obtains the default slot of the SIM card used to send SMS messages. This API use
**Example** **Example**
``` ```js
let promise = sms.getDefaultSmsSlotId(); let promise = sms.getDefaultSmsSlotId();
promise.then(data => { promise.then(data => {
console.log(`getDefaultSmsSlotId success, promise: data->${JSON.stringify(data)}`); console.log(`getDefaultSmsSlotId success, promise: data->${JSON.stringify(data)}`);
...@@ -179,7 +179,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -179,7 +179,7 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
let smscAddr = '+861xxxxxxxxxx'; let smscAddr = '+861xxxxxxxxxx';
sms.setSmscAddr(slotId, smscAddr, (err,data) => { sms.setSmscAddr(slotId, smscAddr, (err,data) => {
...@@ -215,7 +215,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -215,7 +215,7 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
let smscAddr = '+861xxxxxxxxxx'; let smscAddr = '+861xxxxxxxxxx';
let promise = sms.setSmscAddr(slotId, smscAddr); let promise = sms.setSmscAddr(slotId, smscAddr);
...@@ -248,7 +248,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -248,7 +248,7 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
sms.getSmscAddr(slotId, (err, data) => { sms.getSmscAddr(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
...@@ -282,7 +282,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -282,7 +282,7 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
let promise = sms.getSmscAddr(slotId); let promise = sms.getSmscAddr(slotId);
promise.then(data => { promise.then(data => {
...@@ -306,7 +306,7 @@ Checks whether the current device can send and receive SMS messages. This API wo ...@@ -306,7 +306,7 @@ Checks whether the current device can send and receive SMS messages. This API wo
| ------- | ------------------------------------------------------------ | | ------- | ------------------------------------------------------------ |
| boolean | - **true**: The device can send and receive SMS messages.<br>- **false**: The device cannot send or receive SMS messages.| | boolean | - **true**: The device can send and receive SMS messages.<br>- **false**: The device cannot send or receive SMS messages.|
``` ```js
let result = sms.hasSmsCapability(); let result = sms.hasSmsCapability();
console.log(`hasSmsCapability: ${JSON.stringify(result)}`); console.log(`hasSmsCapability: ${JSON.stringify(result)}`);
``` ```
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
## Modules to Import ## Modules to Import
``` ```js
import socket from '@ohos.net.socket'; import socket from '@ohos.net.socket';
``` ```
...@@ -28,7 +28,7 @@ Creates a **UDPSocket** object. ...@@ -28,7 +28,7 @@ Creates a **UDPSocket** object.
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
``` ```
...@@ -56,7 +56,7 @@ Binds the IP address and port number. The port number can be specified or random ...@@ -56,7 +56,7 @@ Binds the IP address and port number. The port number can be specified or random
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => {
if (err) { if (err) {
...@@ -93,7 +93,7 @@ Binds the IP address and port number. The port number can be specified or random ...@@ -93,7 +93,7 @@ Binds the IP address and port number. The port number can be specified or random
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
let promise = udp.bind({address: '192.168.xx.xxx', port: 8080, family: 1}); let promise = udp.bind({address: '192.168.xx.xxx', port: 8080, family: 1});
promise .then(() => { promise .then(() => {
...@@ -123,7 +123,7 @@ Sends data over a UDPSocket connection. This API uses an asynchronous callback t ...@@ -123,7 +123,7 @@ Sends data over a UDPSocket connection. This API uses an asynchronous callback t
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
udp.send({ udp.send({
data:'Hello, server!', data:'Hello, server!',
...@@ -166,7 +166,7 @@ Sends data over a UDPSocket connection. This API uses a promise to return the re ...@@ -166,7 +166,7 @@ Sends data over a UDPSocket connection. This API uses a promise to return the re
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
let promise = udp.send({ let promise = udp.send({
data:'Hello, server!', data:'Hello, server!',
...@@ -202,7 +202,7 @@ Closes a UDPSocket connection. This API uses an asynchronous callback to return ...@@ -202,7 +202,7 @@ Closes a UDPSocket connection. This API uses an asynchronous callback to return
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
udp.close(err => { udp.close(err => {
if (err) { if (err) {
...@@ -232,7 +232,7 @@ Closes a UDPSocket connection. This API uses a promise to return the result. ...@@ -232,7 +232,7 @@ Closes a UDPSocket connection. This API uses a promise to return the result.
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
let promise = udp.close(); let promise = udp.close();
promise.then(() => { promise.then(() => {
...@@ -264,7 +264,7 @@ Obtains the status of the UDPSocket connection. This API uses an asynchronous ca ...@@ -264,7 +264,7 @@ Obtains the status of the UDPSocket connection. This API uses an asynchronous ca
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => {
if (err) { if (err) {
...@@ -304,7 +304,7 @@ Obtains the status of the UDPSocket connection. This API uses a promise to retur ...@@ -304,7 +304,7 @@ Obtains the status of the UDPSocket connection. This API uses a promise to retur
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => {
if (err) { if (err) {
...@@ -345,7 +345,7 @@ Sets other properties of the UDPSocket connection. This API uses an asynchronous ...@@ -345,7 +345,7 @@ Sets other properties of the UDPSocket connection. This API uses an asynchronous
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
udp.bind({address:'192.168.xx.xxx', port:xxxx, family:1}, err=> { udp.bind({address:'192.168.xx.xxx', port:xxxx, family:1}, err=> {
if (err) { if (err) {
...@@ -397,7 +397,7 @@ Sets other properties of the UDPSocket connection. This API uses a promise to re ...@@ -397,7 +397,7 @@ Sets other properties of the UDPSocket connection. This API uses a promise to re
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
let promise = udp.bind({address:'192.168.xx.xxx', port:xxxx, family:1}); let promise = udp.bind({address:'192.168.xx.xxx', port:xxxx, family:1});
promise.then(() => { promise.then(() => {
...@@ -437,7 +437,7 @@ Enables listening for message receiving events of the UDPSocket connection. This ...@@ -437,7 +437,7 @@ Enables listening for message receiving events of the UDPSocket connection. This
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
udp.on('message', value => { udp.on('message', value => {
console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo); console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo);
...@@ -465,7 +465,7 @@ Disables listening for message receiving events of the UDPSocket connection. Thi ...@@ -465,7 +465,7 @@ Disables listening for message receiving events of the UDPSocket connection. Thi
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
let callback = value =>{ let callback = value =>{
console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo); console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo);
...@@ -494,7 +494,7 @@ Enables listening for data packet message events or close events of the UDPSocke ...@@ -494,7 +494,7 @@ Enables listening for data packet message events or close events of the UDPSocke
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
udp.on('listening', () => { udp.on('listening', () => {
console.log("on listening success"); console.log("on listening success");
...@@ -525,7 +525,7 @@ Disables listening for data packet message events or close events of the UDPSock ...@@ -525,7 +525,7 @@ Disables listening for data packet message events or close events of the UDPSock
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
let callback1 = () =>{ let callback1 = () =>{
console.log("on listening, success"); console.log("on listening, success");
...@@ -562,7 +562,7 @@ Enables listening for error events of the UDPSocket connection. This API uses an ...@@ -562,7 +562,7 @@ Enables listening for error events of the UDPSocket connection. This API uses an
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
udp.on('error', err => { udp.on('error', err => {
console.log("on error, err:" + JSON.stringify(err)) console.log("on error, err:" + JSON.stringify(err))
...@@ -590,7 +590,7 @@ Disables listening for error events of the UDPSocket connection. This API uses a ...@@ -590,7 +590,7 @@ Disables listening for error events of the UDPSocket connection. This API uses a
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
let callback = err =>{ let callback = err =>{
console.log("on error, err:" + JSON.stringify(err)); console.log("on error, err:" + JSON.stringify(err));
...@@ -680,7 +680,7 @@ Creates a **TCPSocket** object. ...@@ -680,7 +680,7 @@ Creates a **TCPSocket** object.
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
``` ```
...@@ -709,7 +709,7 @@ Binds the IP address and port number. The port number can be specified or random ...@@ -709,7 +709,7 @@ Binds the IP address and port number. The port number can be specified or random
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
tcp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { tcp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => {
if (err) { if (err) {
...@@ -745,7 +745,7 @@ Binds the IP address and port number. The port number can be specified or random ...@@ -745,7 +745,7 @@ Binds the IP address and port number. The port number can be specified or random
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let promise = tcp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}); let promise = tcp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1});
promise.then(() => { promise.then(() => {
...@@ -775,7 +775,7 @@ Sets up a connection to the specified IP address and port number. This API uses ...@@ -775,7 +775,7 @@ Sets up a connection to the specified IP address and port number. This API uses
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}, err => { tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}, err => {
if (err) { if (err) {
...@@ -811,7 +811,7 @@ Sets up a connection to the specified IP address and port number. This API uses ...@@ -811,7 +811,7 @@ Sets up a connection to the specified IP address and port number. This API uses
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise.then(() => { promise.then(() => {
...@@ -844,7 +844,7 @@ Sends data over a TCPSocket connection. This API uses an asynchronous callback t ...@@ -844,7 +844,7 @@ Sends data over a TCPSocket connection. This API uses an asynchronous callback t
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise.then(() => { promise.then(() => {
...@@ -891,7 +891,7 @@ Sends data over a TCPSocket connection. This API uses a promise to return the re ...@@ -891,7 +891,7 @@ Sends data over a TCPSocket connection. This API uses a promise to return the re
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let promise1 = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); let promise1 = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise1.then(() => { promise1.then(() => {
...@@ -929,7 +929,7 @@ Closes a TCPSocket connection. This API uses an asynchronous callback to return ...@@ -929,7 +929,7 @@ Closes a TCPSocket connection. This API uses an asynchronous callback to return
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
tcp.close(err => { tcp.close(err => {
if (err) { if (err) {
...@@ -959,7 +959,7 @@ Closes a TCPSocket connection. This API uses a promise to return the result. ...@@ -959,7 +959,7 @@ Closes a TCPSocket connection. This API uses a promise to return the result.
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let promise = tcp.close(); let promise = tcp.close();
promise.then(() => { promise.then(() => {
...@@ -991,7 +991,7 @@ Obtains the remote address of a TCPSocket connection. This API uses an asynchron ...@@ -991,7 +991,7 @@ Obtains the remote address of a TCPSocket connection. This API uses an asynchron
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise.then(() => { promise.then(() => {
...@@ -1030,7 +1030,7 @@ Obtains the remote address of a TCPSocket connection. This API uses a promise to ...@@ -1030,7 +1030,7 @@ Obtains the remote address of a TCPSocket connection. This API uses a promise to
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let promise1 = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); let promise1 = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise1.then(() => { promise1.then(() => {
...@@ -1069,7 +1069,7 @@ Obtains the status of the TCPSocket connection. This API uses an asynchronous ca ...@@ -1069,7 +1069,7 @@ Obtains the status of the TCPSocket connection. This API uses an asynchronous ca
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise.then(() => { promise.then(() => {
...@@ -1109,7 +1109,7 @@ Obtains the status of the TCPSocket connection. This API uses a promise to retur ...@@ -1109,7 +1109,7 @@ Obtains the status of the TCPSocket connection. This API uses a promise to retur
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise.then(() => { promise.then(() => {
...@@ -1148,7 +1148,7 @@ Sets other properties of the TCPSocket connection. This API uses an asynchronous ...@@ -1148,7 +1148,7 @@ Sets other properties of the TCPSocket connection. This API uses an asynchronous
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise.then(() => { promise.then(() => {
...@@ -1203,7 +1203,7 @@ Sets other properties of the TCPSocket connection. This API uses a promise to re ...@@ -1203,7 +1203,7 @@ Sets other properties of the TCPSocket connection. This API uses a promise to re
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise.then(() => { promise.then(() => {
...@@ -1246,7 +1246,7 @@ Enables listening for message receiving events of the TCPSocket connection. This ...@@ -1246,7 +1246,7 @@ Enables listening for message receiving events of the TCPSocket connection. This
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
tcp.on('message', value => { tcp.on('message', value => {
console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo) console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo)
...@@ -1274,7 +1274,7 @@ Disables listening for message receiving events of the TCPSocket connection. Thi ...@@ -1274,7 +1274,7 @@ Disables listening for message receiving events of the TCPSocket connection. Thi
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let callback = value =>{ let callback = value =>{
console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo); console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo);
...@@ -1304,7 +1304,7 @@ Enables listening for connection or close events of the TCPSocket connection. Th ...@@ -1304,7 +1304,7 @@ Enables listening for connection or close events of the TCPSocket connection. Th
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
tcp.on('connect', () => { tcp.on('connect', () => {
console.log("on connect success") console.log("on connect success")
...@@ -1335,7 +1335,7 @@ Disables listening for connection or close events of the TCPSocket connection. T ...@@ -1335,7 +1335,7 @@ Disables listening for connection or close events of the TCPSocket connection. T
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let callback1 = () =>{ let callback1 = () =>{
console.log("on connect success"); console.log("on connect success");
...@@ -1371,7 +1371,7 @@ Enables listening for error events of the TCPSocket connection. This API uses an ...@@ -1371,7 +1371,7 @@ Enables listening for error events of the TCPSocket connection. This API uses an
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
tcp.on('error', err => { tcp.on('error', err => {
console.log("on error, err:" + JSON.stringify(err)) console.log("on error, err:" + JSON.stringify(err))
...@@ -1399,7 +1399,7 @@ Disables listening for error events of the TCPSocket connection. This API uses a ...@@ -1399,7 +1399,7 @@ Disables listening for error events of the TCPSocket connection. This API uses a
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let callback = err =>{ let callback = err =>{
console.log("on error, err:" + JSON.stringify(err)); console.log("on error, err:" + JSON.stringify(err));
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
## Modules to Import ## Modules to Import
``` ```js
import usb from "@ohos.usb"; import usb from "@ohos.usb";
``` ```
...@@ -17,13 +17,13 @@ Obtains the USB device list. ...@@ -17,13 +17,13 @@ Obtains the USB device list.
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Return value - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Array&lt;Readonly&lt;[USBDevice](#usbdevice)&gt;&gt; | Device information list.| | Array&lt;Readonly&lt;[USBDevice](#usbdevice)&gt;&gt; | Device information list.|
- Example - **Example**
``` ```js
let devicesList = usb.getDevices(); let devicesList = usb.getDevices();
console.log(`devicesList = ${JSON.stringify(devicesList)}`); console.log(`devicesList = ${JSON.stringify(devicesList)}`);
// devicesList is a list of USB devices. // devicesList is a list of USB devices.
...@@ -89,18 +89,18 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -89,18 +89,18 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Parameters - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| device | [USBDevice](#usbdevice) | Yes| USB device information.| | device | [USBDevice](#usbdevice) | Yes| USB device information.|
- Return value - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Readonly&lt;[USBDevicePipe](#usbdevicepipe)&gt; | USB device pipe for data transfer.| | Readonly&lt;[USBDevicePipe](#usbdevicepipe)&gt; | USB device pipe for data transfer.|
- Example - **Example**
``` ```js
let devicepipe= usb.connectDevice(device); let devicepipe= usb.connectDevice(device);
console.log(`devicepipe = ${JSON.stringify(devicepipe)}`); console.log(`devicepipe = ${JSON.stringify(devicepipe)}`);
``` ```
...@@ -114,18 +114,18 @@ Checks whether the application has the permission to access the device. ...@@ -114,18 +114,18 @@ Checks whether the application has the permission to access the device.
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Parameters - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| deviceName | string | Yes| Device name.| | deviceName | string | Yes| Device name.|
- Return value - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the application has the permission to access the device; returns **false** otherwise.| | boolean | Returns **true** if the application has the permission to access the device; returns **false** otherwise.|
- Example - **Example**
``` ```js
let divicesName="1-1"; let divicesName="1-1";
let bool = usb.hasRight(divicesName); let bool = usb.hasRight(divicesName);
console.log(bool); console.log(bool);
...@@ -140,18 +140,18 @@ Requests the temporary permission for the application to access the USB device. ...@@ -140,18 +140,18 @@ Requests the temporary permission for the application to access the USB device.
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Parameters - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| deviceName | string | Yes| Device name.| | deviceName | string | Yes| Device name.|
- Return value - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | Returns **true** if the temporary device access permissions are granted; returns **false** otherwise.| | Promise&lt;boolean&gt; | Returns **true** if the temporary device access permissions are granted; returns **false** otherwise.|
- Example - **Example**
``` ```js
let divicesName="1-1"; let divicesName="1-1";
usb.requestRight(divicesName).then((ret) => { usb.requestRight(divicesName).then((ret) => {
console.log(`requestRight = ${JSON.stringify(ret)}`); console.log(`requestRight = ${JSON.stringify(ret)}`);
...@@ -169,20 +169,20 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -169,20 +169,20 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Parameters - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
| iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to claim.| | iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to claim.|
| force | boolean | No| Whether to forcibly claim the USB interface. The default value is **false**, indicating not to forcibly claim the USB interface.| | force | boolean | No| Whether to forcibly claim the USB interface. The default value is **false**, indicating not to forcibly claim the USB interface.|
- Return value - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | Returns **0** if the USB interface is successfully claimed; returns an error code otherwise.| | number | Returns **0** if the USB interface is successfully claimed; returns an error code otherwise.|
- Example - **Example**
``` ```js
let ret = usb.claimInterface(devicepipe, interfaces); let ret = usb.claimInterface(devicepipe, interfaces);
console.log(`claimInterface = ${ret}`); console.log(`claimInterface = ${ret}`);
``` ```
...@@ -198,19 +198,19 @@ Before you do this, ensure that you have claimed the interface by calling [usb.c ...@@ -198,19 +198,19 @@ Before you do this, ensure that you have claimed the interface by calling [usb.c
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Parameters - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
| iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to release.| | iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to release.|
- Return value - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | Returns **0** if the USB interface is successfully released; returns an error code otherwise.| | number | Returns **0** if the USB interface is successfully released; returns an error code otherwise.|
- Example - **Example**
``` ```js
let ret = usb.releaseInterface(devicepipe, interfaces); let ret = usb.releaseInterface(devicepipe, interfaces);
console.log(`releaseInterface = ${ret}`); console.log(`releaseInterface = ${ret}`);
``` ```
...@@ -226,19 +226,19 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -226,19 +226,19 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Parameters - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
| config | [USBConfig](#usbconfig) | Yes| USB configuration to set.| | config | [USBConfig](#usbconfig) | Yes| USB configuration to set.|
- Return value - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | Returns **0** if the USB configuration is successfully set; returns an error code otherwise.| | number | Returns **0** if the USB configuration is successfully set; returns an error code otherwise.|
- Example - **Example**
``` ```js
let ret = usb.setConfiguration(devicepipe, config); let ret = usb.setConfiguration(devicepipe, config);
console.log(`setConfiguration = ${ret}`); console.log(`setConfiguration = ${ret}`);
``` ```
...@@ -254,19 +254,19 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -254,19 +254,19 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Parameters - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
| iface | [USBInterface](#usbinterface) | Yes| USB interface to set.| | iface | [USBInterface](#usbinterface) | Yes| USB interface to set.|
- Return value - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | Returns **0** if the USB interface is successfully set; returns an error code otherwise.| | number | Returns **0** if the USB interface is successfully set; returns an error code otherwise.|
- Example - **Example**
``` ```js
let ret = usb.setInterface(devicepipe, interfaces); let ret = usb.setInterface(devicepipe, interfaces);
console.log(`setInterface = ${ret}`); console.log(`setInterface = ${ret}`);
``` ```
...@@ -282,18 +282,18 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -282,18 +282,18 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Parameters - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
- Return value - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Uint8Array | Raw descriptor data.| | Uint8Array | Raw descriptor data.|
- Example - **Example**
``` ```js
let ret = usb.getRawDescriptor(devicepipe); let ret = usb.getRawDescriptor(devicepipe);
``` ```
...@@ -308,18 +308,18 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -308,18 +308,18 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Parameters - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
- Return value - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | File descriptor of the USB device.| | number | File descriptor of the USB device.|
- Example - **Example**
``` ```js
let ret = usb.getFileDescriptor(devicepipe); let ret = usb.getFileDescriptor(devicepipe);
``` ```
...@@ -334,20 +334,20 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -334,20 +334,20 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Parameters - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device.| | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device.|
| contrlparam | [USBControlParams](#usbcontrolparams) | Yes| Control transfer parameters.| | contrlparam | [USBControlParams](#usbcontrolparams) | Yes| Control transfer parameters.|
| timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout.| | timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout.|
- Return value - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs.| | Promise&lt;number&gt; | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs.|
- Example - **Example**
``` ```js
usb.controlTransfer(devicepipe, USBControlParams).then((ret) => { usb.controlTransfer(devicepipe, USBControlParams).then((ret) => {
console.log(`controlTransfer = ${JSON.stringify(ret)}`); console.log(`controlTransfer = ${JSON.stringify(ret)}`);
}) })
...@@ -364,7 +364,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -364,7 +364,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Parameters - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device.| | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device.|
...@@ -372,13 +372,13 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -372,13 +372,13 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
| buffer | Uint8Array | Yes| Buffer for writing or reading data.| | buffer | Uint8Array | Yes| Buffer for writing or reading data.|
| timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout.| | timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout.|
- Return value - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs.| | Promise&lt;number&gt; | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs.|
- Example - **Example**
``` ```js
// Call usb.getDevices to obtain a data set. Then, obtain a USB device and its access permission. // Call usb.getDevices to obtain a data set. Then, obtain a USB device and its access permission.
// Pass the obtained USB device as a parameter to usb.connectDevice. Then, call usb.connectDevice to connect the USB device. // Pass the obtained USB device as a parameter to usb.connectDevice. Then, call usb.connectDevice to connect the USB device.
// Call usb.claimInterface to claim the USB interface. After that, call usb.bulkTransfer to start bulk transfer. // Call usb.claimInterface to claim the USB interface. After that, call usb.bulkTransfer to start bulk transfer.
...@@ -398,18 +398,18 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -398,18 +398,18 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Parameters - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe.| | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe.|
- Return value - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | Returns **0** if the USB device pipe is closed successfully; returns an error code otherwise.| | number | Returns **0** if the USB device pipe is closed successfully; returns an error code otherwise.|
- Example - **Example**
``` ```js
let ret = usb.closePipe(devicepipe); let ret = usb.closePipe(devicepipe);
console.log(`closePipe = ${ret}`); console.log(`closePipe = ${ret}`);
``` ```
......
...@@ -12,13 +12,13 @@ If an error occurs in any of the preceding processes, the client will receive a ...@@ -12,13 +12,13 @@ If an error occurs in any of the preceding processes, the client will receive a
## Modules to Import ## Modules to Import
``` ```js
import webSocket from '@ohos.net.webSocket'; import webSocket from '@ohos.net.webSocket';
``` ```
## Complete Example ## Complete Example
``` ```js
import webSocket from '@ohos.net.webSocket'; import webSocket from '@ohos.net.webSocket';
var defaultIpAddress = "ws://"; var defaultIpAddress = "ws://";
...@@ -78,7 +78,7 @@ Creates a WebSocket connection. You can use this API to create or close a WebSoc ...@@ -78,7 +78,7 @@ Creates a WebSocket connection. You can use this API to create or close a WebSoc
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
``` ```
...@@ -107,7 +107,7 @@ Initiates a WebSocket request to establish a WebSocket connection to a given URL ...@@ -107,7 +107,7 @@ Initiates a WebSocket request to establish a WebSocket connection to a given URL
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
let url = "ws://" let url = "ws://"
ws.connect(url, (err, value) => { ws.connect(url, (err, value) => {
...@@ -141,7 +141,7 @@ Initiates a WebSocket request carrying specified options to establish a WebSocke ...@@ -141,7 +141,7 @@ Initiates a WebSocket request carrying specified options to establish a WebSocke
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
let url = "ws://" let url = "ws://"
ws.connect(url, { ws.connect(url, {
...@@ -184,7 +184,7 @@ Initiates a WebSocket request carrying specified options to establish a WebSocke ...@@ -184,7 +184,7 @@ Initiates a WebSocket request carrying specified options to establish a WebSocke
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
let url = "ws://" let url = "ws://"
let promise = ws.connect(url); let promise = ws.connect(url);
...@@ -215,7 +215,7 @@ Sends data through a WebSocket connection. This API uses an asynchronous callbac ...@@ -215,7 +215,7 @@ Sends data through a WebSocket connection. This API uses an asynchronous callbac
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
let url = "ws://" let url = "ws://"
ws.connect(url, (err, value) => { ws.connect(url, (err, value) => {
...@@ -254,7 +254,7 @@ Sends data through a WebSocket connection. This API uses a promise to return the ...@@ -254,7 +254,7 @@ Sends data through a WebSocket connection. This API uses a promise to return the
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
let url = "ws://" let url = "ws://"
ws.connect(url, (err, value) => { ws.connect(url, (err, value) => {
...@@ -286,7 +286,7 @@ Closes a WebSocket connection. This API uses an asynchronous callback to return ...@@ -286,7 +286,7 @@ Closes a WebSocket connection. This API uses an asynchronous callback to return
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
let url = "ws://" let url = "ws://"
ws.close((err, value) => { ws.close((err, value) => {
...@@ -318,7 +318,7 @@ Closes a WebSocket connection carrying specified options such as **code** and ** ...@@ -318,7 +318,7 @@ Closes a WebSocket connection carrying specified options such as **code** and **
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
let url = "ws://" let url = "ws://"
ws.close({ ws.close({
...@@ -358,7 +358,7 @@ Closes a WebSocket connection carrying specified options such as **code** and ** ...@@ -358,7 +358,7 @@ Closes a WebSocket connection carrying specified options such as **code** and **
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
let url = "ws://" let url = "ws://"
let promise = ws.close({ let promise = ws.close({
...@@ -391,7 +391,7 @@ Enables listening for the **open** events of a WebSocket connection. This API us ...@@ -391,7 +391,7 @@ Enables listening for the **open** events of a WebSocket connection. This API us
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
ws.on('open', (err, value) => { ws.on('open', (err, value) => {
console.log("on open, status:" + value.status + ", message:" + value.message); console.log("on open, status:" + value.status + ", message:" + value.message);
...@@ -419,7 +419,7 @@ Disables listening for the **open** events of a WebSocket connection. This API u ...@@ -419,7 +419,7 @@ Disables listening for the **open** events of a WebSocket connection. This API u
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
let callback1 = (err, value) => { let callback1 = (err, value) => {
console.log("on open, status:" + value.status + ", message:" + value.message); console.log("on open, status:" + value.status + ", message:" + value.message);
...@@ -451,7 +451,7 @@ Enables listening for the **message** events of a WebSocket connection. This API ...@@ -451,7 +451,7 @@ Enables listening for the **message** events of a WebSocket connection. This API
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
ws.on('message', (err, value) => { ws.on('message', (err, value) => {
console.log("on message, message:" + value); console.log("on message, message:" + value);
...@@ -480,7 +480,7 @@ Disables listening for the **message** events of a WebSocket connection. This AP ...@@ -480,7 +480,7 @@ Disables listening for the **message** events of a WebSocket connection. This AP
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
ws.off('message'); ws.off('message');
``` ```
...@@ -503,7 +503,7 @@ Enables listening for the **close** events of a WebSocket connection. This API u ...@@ -503,7 +503,7 @@ Enables listening for the **close** events of a WebSocket connection. This API u
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
ws.on('close', (err, value) => { ws.on('close', (err, value) => {
console.log("on close, code is " + value.code + ", reason is " + value.reason); console.log("on close, code is " + value.code + ", reason is " + value.reason);
...@@ -532,7 +532,7 @@ Disables listening for the **close** events of a WebSocket connection. This API ...@@ -532,7 +532,7 @@ Disables listening for the **close** events of a WebSocket connection. This API
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
ws.off('close'); ws.off('close');
``` ```
...@@ -556,7 +556,7 @@ Enables listening for the **error** events of a WebSocket connection. This API u ...@@ -556,7 +556,7 @@ Enables listening for the **error** events of a WebSocket connection. This API u
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
ws.on('error', (err) => { ws.on('error', (err) => {
console.log("on error, error:" + JSON.stringify(err)) console.log("on error, error:" + JSON.stringify(err))
...@@ -584,7 +584,7 @@ Disables listening for the **error** events of a WebSocket connection. This API ...@@ -584,7 +584,7 @@ Disables listening for the **error** events of a WebSocket connection. This API
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
ws.off('error'); ws.off('error');
``` ```
......
# webgl # webgl
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -11,18 +11,18 @@ This module provides WebGL APIs that correspond to the OpenGL ES 2.0 feature set ...@@ -11,18 +11,18 @@ This module provides WebGL APIs that correspond to the OpenGL ES 2.0 feature set
Create a **<canvas\>** component in the HML file. The following is an example: Create a **<canvas\>** component in the HML file. The following is an example:
``` ```
<div class="container">
<canvas ref="canvas1" style="width : 400px; height : 200px; background-color : lightyellow;"></canvas>
<button class="btn-button" onclick="BtnDraw2D">BtnDraw2D</button> <button class="btn-button" onclick="BtnDraw2D">BtnDraw2D</button>
</div>
``` ```
Obtain the **<canvas\>** component instance in the JS file. The following is an example: Obtain the **<canvas\>** component instance in the JS file. The following is an example:
``` ```js
// Obtain the <canvas> component instance. // Obtain the <canvas> component instance.
const el = this.$refs.canvas1; const el = this.$refs.canvas1;
// Obtain the WebGL context from the <canvas> component instance. // Obtain the WebGL context from the <canvas> component instance.
......
# webgl2 # webgl2
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -11,18 +11,18 @@ This module provides WebGL APIs that correspond to the OpenGL ES 3.0 feature set ...@@ -11,18 +11,18 @@ This module provides WebGL APIs that correspond to the OpenGL ES 3.0 feature set
Create a **<canvas\>** component in the HML file. The following is an example: Create a **<canvas\>** component in the HML file. The following is an example:
``` ```
<div class="container">
<canvas ref="canvas1" style="width : 400px; height : 200px; background-color : lightyellow;"></canvas>
<button class="btn-button" onclick="BtnDraw2D">BtnDraw2D</button> <button class="btn-button" onclick="BtnDraw2D">BtnDraw2D</button>
</div>
``` ```
Obtain the **<canvas\>** component instance in the JS file. The following is an example: Obtain the **<canvas\>** component instance in the JS file. The following is an example:
``` ```js
// Obtain the <canvas> component instance. // Obtain the <canvas> component instance.
const el = this.$refs.canvas1; const el = this.$refs.canvas1;
// Obtain the WebGL context from the <canvas> component instance. // Obtain the WebGL context from the <canvas> component instance.
......
...@@ -240,8 +240,8 @@ typedef struct { // Good: The anonymous struct is used because self-nesting i ...@@ -240,8 +240,8 @@ typedef struct { // Good: The anonymous struct is used because self-nesting i
int a; int a;
int b; int b;
} MyType; // The struct alias uses the UpperCamelCase style. } MyType; // The struct alias uses the UpperCamelCase style.
```
```c ```c
typedef struct tagNode { // Good: Add the 'tag' prefix or use 'Node_'. typedef struct tagNode { // Good: Add the 'tag' prefix or use 'Node_'.
struct tagNode *prev; struct tagNode *prev;
struct tagNode *next; struct tagNode *next;
......
...@@ -70,9 +70,9 @@ The HDF-based driver development involves driver implementation and configuratio ...@@ -70,9 +70,9 @@ The HDF-based driver development involves driver implementation and configuratio
2. Build the driver.<br/> 2. Build the driver.<br/>
- LiteOS<br/> - LiteOS<br/>
Modify **makefile** and **BUILD.gn**. Modify the **Makefile** and **BUILD.gn** files.
- **makefile**:<br/> - **Makefile**:<br/>
Use the **makefile** template provided by the HDF to compile the driver code. Use the **makefile** template provided by the HDF to compile the driver code.
...@@ -90,7 +90,7 @@ The HDF-based driver development involves driver implementation and configuratio ...@@ -90,7 +90,7 @@ The HDF-based driver development involves driver implementation and configuratio
``` ```
LITEOS_BASELIB += -lxxx # Static library generated by the link. LITEOS_BASELIB += -lxxx # Static library generated by the link.
LIB_SUBDIRS += # Directory in which the driver code makefile is located. LIB_SUBDIRS += # Directory in which Makefile is located.
``` ```
- **BUILD.gn**:<br/> - **BUILD.gn**:<br/>
...@@ -141,7 +141,7 @@ The HDF-based driver development involves driver implementation and configuratio ...@@ -141,7 +141,7 @@ The HDF-based driver development involves driver implementation and configuratio
obj-$(CONFIG_DRIVERS_HDF) += xxx/ obj-$(CONFIG_DRIVERS_HDF) += xxx/
``` ```
Add a **Makefile** to the driver directory **xxx** and add code compiling rules of the driver to the **Makefile** file. Add a **Makefile** to the driver directory **xxx** and add code compiling rules of the driver to the file.
``` ```
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
The WLAN module is developed based on the Hardware Driver Foundation \(HDF\). It supports cross-OS migration, component adaptation, and modular assembly and compilation. Based on the unified APIs provided by the WLAN module, driver developers of WLAN vendors can adapt their driver code and are capable of creating, disabling, scanning, and connecting to WLAN hotspots. The WLAN driver provides the Hardware Device Interface \(HDI\) layer with the capabilities of setting and obtaining the device MAC address and setting the transmit power. The following figure shows the framework of the WLAN module: The WLAN module is developed based on the Hardware Driver Foundation \(HDF\). It supports cross-OS migration, component adaptation, and modular assembly and compilation. Based on the unified APIs provided by the WLAN module, driver developers of WLAN vendors can adapt their driver code and are capable of creating, disabling, scanning, and connecting to WLAN hotspots. The WLAN driver provides the Hardware Device Interface \(HDI\) layer with the capabilities of setting and obtaining the device MAC address and setting the transmit power. The following figure shows the framework of the WLAN module:
**Figure 1** WLAN framework<a name="fig4415112614415"></a> **Figure 1** WLAN framework<a name="fig4415112614415"></a>
![](figures/wlan-framework.png "wlan-framework") ![](figures/wlan-framework.png "wlan-framework")
### WLAN Driver API Architecture<a name="section178022416377"></a> ### WLAN Driver API Architecture<a name="section178022416377"></a>
...@@ -17,14 +17,14 @@ The WLAN module provides the following three types of APIs: ...@@ -17,14 +17,14 @@ The WLAN module provides the following three types of APIs:
3. Capability APIs for vendors 3. Capability APIs for vendors
**Figure 2** Available APIs of the WLAN module<a name="fig1492411431166"></a> **Figure 2** Available APIs of the WLAN module<a name="fig1492411431166"></a>
![](figures/available-apis-of-the-wlan-module.png "available-apis-of-the-wlan-module") ![](figures/available-apis-of-the-wlan-module.png "available-apis-of-the-wlan-module")
## Available APIs<a name="section7331102018815"></a> ## Available APIs<a name="section7331102018815"></a>
The WLAN driver module provides APIs that can be directly called by driver developers, such as creating/releasing a **WifiModule**, connecting to/disconnecting from a WLAN hotspot, applying for/releasing a **NetBuf**, and converting between the **pbuf** structure of Lightweight IP \(lwIP\) and a **NetBuf**. [Table 1](#table1521573319472) describes some APIs. The WLAN driver module provides APIs that can be directly called by driver developers, such as creating/releasing a **WifiModule**, connecting to/disconnecting from a WLAN hotspot, applying for/releasing a **NetBuf**, and converting between the **pbuf** structure of Lightweight IP \(lwIP\) and a **NetBuf**. [Table 1](#table1521573319472) describes some APIs.
**Table 1** APIs that can be directly called by driver developers **Table 1** APIs that can be directly called by driver developers
<a name="table1521573319472"></a> <a name="table1521573319472"></a>
<table><thead align="left"><tr id="row121519334474"><th class="cellrowborder" valign="top" width="15.079999999999998%" id="mcps1.2.4.1.1"><p id="p1221510339475"><a name="p1221510339475"></a><a name="p1221510339475"></a>File</p> <table><thead align="left"><tr id="row121519334474"><th class="cellrowborder" valign="top" width="15.079999999999998%" id="mcps1.2.4.1.1"><p id="p1221510339475"><a name="p1221510339475"></a><a name="p1221510339475"></a>File</p>
...@@ -110,9 +110,9 @@ The WLAN driver module provides APIs that can be directly called by driver devel ...@@ -110,9 +110,9 @@ The WLAN driver module provides APIs that can be directly called by driver devel
</tbody> </tbody>
</table> </table>
The WLAN driver module provides APIs for driver developers, such as initializing/deregistering, opening/stopping a **NetDevice**, and obtaining the state of a **NetDevice**. [Table 2](#table74613501475) describes some APIs. The WLAN driver module provides APIs for driver developers, such as initializing/deregistering, opening/stopping a **NetDevice**, and obtaining the state of a **NetDevice**. [Table 2](#table74613501475) describes some APIs.
**Table 2** APIs for driver developers of WLAN vendors to implement **Table 2** APIs for driver developers of WLAN vendors to implement
<a name="table74613501475"></a> <a name="table74613501475"></a>
<table><thead align="left"><tr id="row194625016476"><th class="cellrowborder" valign="top" width="20.75%" id="mcps1.2.4.1.1"><p id="p10468502479"><a name="p10468502479"></a><a name="p10468502479"></a>File</p> <table><thead align="left"><tr id="row194625016476"><th class="cellrowborder" valign="top" width="20.75%" id="mcps1.2.4.1.1"><p id="p10468502479"><a name="p10468502479"></a><a name="p10468502479"></a>File</p>
...@@ -158,9 +158,9 @@ The WLAN driver module provides APIs for driver developers, such as initializing ...@@ -158,9 +158,9 @@ The WLAN driver module provides APIs for driver developers, such as initializing
</tbody> </tbody>
</table> </table>
The WLAN driver provides the HDI layer with the APIs for creating and destroying an **IWiFi** object and setting the MAC address. [Table 3](#table141076311618) describes some APIs. The WLAN driver provides the HDI layer with the APIs for creating and destroying an **IWiFi** object and setting the MAC address. [Table 3](#table141076311618) describes some APIs.
**Table 3** APIs provided by the WLAN HAL module **Table 3** APIs provided by the WLAN HAL module
<a name="table141076311618"></a> <a name="table141076311618"></a>
<table><thead align="left"><tr id="row010716312120"><th class="cellrowborder" valign="top" width="15.950000000000001%" id="mcps1.2.4.1.1"><p id="p1110713311116"><a name="p1110713311116"></a><a name="p1110713311116"></a>Header File</p> <table><thead align="left"><tr id="row010716312120"><th class="cellrowborder" valign="top" width="15.950000000000001%" id="mcps1.2.4.1.1"><p id="p1110713311116"><a name="p1110713311116"></a><a name="p1110713311116"></a>Header File</p>
...@@ -223,14 +223,14 @@ The WLAN driver provides the HDI layer with the APIs for creating and destroying ...@@ -223,14 +223,14 @@ The WLAN driver provides the HDI layer with the APIs for creating and destroying
The WLAN driver is developed based on the HDF and PLATFORM. It provides a unified driver model for WLAN modules of different vendors regardless of the operating system \(OS\) and system on a chip \(SoC\). The WLAN driver is developed based on the HDF and PLATFORM. It provides a unified driver model for WLAN modules of different vendors regardless of the operating system \(OS\) and system on a chip \(SoC\).
1. Set hardware parameters such as **module** \(different features\) and **chip** in the **wifi\_config.hcs** file. 1. Set hardware parameters such as **module** \(different features\) and **chip** in the **wifi\_config.hcs** file.
2. Parse the **wifi\_config.hcs** file and generate a structure with the configured parameters. 2. Parse the **wifi\_config.hcs** file and generate a structure with the configured parameters.
3. Initialize and create a module. 3. Initialize and create a module.
4. Mount and initialize the chip. 4. Mount and initialize the chip.
5. Initialize the bus. 5. Initialize the bus.
6. Mount the upper-layer WPA service. 6. Mount the upper-layer WPA service.
>![](../public_sys-resources/icon-note.gif) **NOTE:** >![](../public_sys-resources/icon-note.gif) **NOTE:**<br>
>Some of the above adaptation steps have been provided. For details, see [Development Example](#section1395253612512). The steps waiting to be performed by developers include setting configuration parameters based on hardware attributes, adapting and mounting a chip, and performing tests and verification. >Some of the above adaptation steps have been provided. For details, see [Development Example](#section1395253612512). The steps waiting to be performed by developers include setting configuration parameters based on hardware attributes, adapting and mounting a chip, and performing tests and verification.
## Development Example<a name="section1395253612512"></a> ## Development Example<a name="section1395253612512"></a>
...@@ -289,7 +289,7 @@ root { ...@@ -289,7 +289,7 @@ root {
} }
``` ```
2. Mount the **init** and **deinit** functions of the WLAN chip and WLAN chip driver. 2. Mount the **init** and **deinit** functions of the WLAN chip and WLAN chip driver.
``` ```
/* WLAN module initialization and mount process */ /* WLAN module initialization and mount process */
...@@ -504,7 +504,7 @@ int32_t Hi3881Deinit(struct HdfChipDriver *chipDriver, struct NetDevice *netDevi ...@@ -504,7 +504,7 @@ int32_t Hi3881Deinit(struct HdfChipDriver *chipDriver, struct NetDevice *netDevi
} }
``` ```
3. During the chip initialization, call the **NetDeviceInit\(\)** function to initialize a network device, call the **NetDeviceAdd\(\)** function to add the network device to a protocol stack, and implement some function pointers of **netdev**. 3. During the chip initialization, call the **NetDeviceInit\(\)** function to initialize a network device, call the **NetDeviceAdd\(\)** function to add the network device to a protocol stack, and implement some function pointers of **netdev**.
``` ```
hi_s32 wal_init_drv_wlan_netdev(nl80211_iftype_uint8 type, wal_phy_mode mode, hi_char* ifname, hi_u32* len) hi_s32 wal_init_drv_wlan_netdev(nl80211_iftype_uint8 type, wal_phy_mode mode, hi_char* ifname, hi_u32* len)
...@@ -553,7 +553,7 @@ hi_s32 wal_init_netif(nl80211_iftype_uint8 type, oal_net_device_stru *netdev, co ...@@ -553,7 +553,7 @@ hi_s32 wal_init_netif(nl80211_iftype_uint8 type, oal_net_device_stru *netdev, co
} }
``` ```
4. Implement functions of **WifiMac80211Ops**. 4. Implement functions of **WifiMac80211Ops**.
``` ```
/* Mount some function pointers of mac80211. */ /* Mount some function pointers of mac80211. */
...@@ -603,5 +603,4 @@ hi_void HiMac80211Init(struct HdfChipDriver *chipDriver) ...@@ -603,5 +603,4 @@ hi_void HiMac80211Init(struct HdfChipDriver *chipDriver)
chipDriver->staOps = &g_staOps; chipDriver->staOps = &g_staOps;
chipDriver->apOps = &g_apOps; chipDriver->apOps = &g_apOps;
} }
``` ```
\ No newline at end of file
...@@ -112,8 +112,6 @@ The sensor driver model also provides certain driver development APIs that need ...@@ -112,8 +112,6 @@ The sensor driver model also provides certain driver development APIs that need
| void ReadSensorData(void) | Reads sensor data.| | void ReadSensorData(void) | Reads sensor data.|
For details about the interface implementation, see "How to Develop" below.
### How to Develop ### How to Develop
1. Develop the acceleration sensor abstract driver. Specifically, implement the **Bind**, **Init**, **Release**, and **Dispatch** functions. 1. Develop the acceleration sensor abstract driver. Specifically, implement the **Bind**, **Init**, **Release**, and **Dispatch** functions.
......
...@@ -50,17 +50,17 @@ Based on the attributes of the pins, interfaces on the touchscreens can be class ...@@ -50,17 +50,17 @@ Based on the attributes of the pins, interfaces on the touchscreens can be class
The interfaces shown in the figure are described as follows: The interfaces shown in the figure are described as follows:
1. **Power interfaces** - **Power interfaces**
- LDO\_1P8: 1.8 V digital circuits - LDO\_1P8: 1.8 V digital circuits
- LDO\_3P3: 3.3 V analog circuits - LDO\_3P3: 3.3 V analog circuits
Generally, the touchscreen driver IC is separated from the LCD driver IC. In this case, the touchscreen driver IC requires both 1.8 V and 3.3 V power supplies. Nowadays, the touchscreen driver IC and LCD driver IC can be integrated. Therefore, the touchscreen, requires only the 1.8 V power supply, and the 3.3 V power required internally is supplied by the LCD VSP power \(typical value: 5.5 V\) in the driver IC. Generally, the touchscreen driver IC is separated from the LCD driver IC. In this case, the touchscreen driver IC requires both 1.8 V and 3.3 V power supplies. Nowadays, the touchscreen driver IC and LCD driver IC can be integrated. Therefore, the touchscreen, requires only the 1.8 V power supply, and the 3.3 V power required internally is supplied by the LCD VSP power \(typical value: 5.5 V\) in the driver IC.
2. **I/O control interfaces** - **I/O control interfaces**
- RESET: reset pin, which is used to reset the driver IC on the host when suspending or resuming the system. - RESET: reset pin, which is used to reset the driver IC on the host when suspending or resuming the system.
- INT: interrupt pin, which needs to be set to the input direction and pull-up status during driver initialization. After detecting an external touch signal, the driver triggers the interrupt by operating the interrupt pin. The driver reads the touch reporting data in the ISR function. - INT: interrupt pin, which needs to be set to the input direction and pull-up status during driver initialization. After detecting an external touch signal, the driver triggers the interrupt by operating the interrupt pin. The driver reads the touch reporting data in the ISR function.
3. **Communications interfaces** - **Communications interfaces**
- I2C: Since only a small amount of touch data is reported by the touchscreen, I2C is used to transmit the reported data. For details about the I2C protocol and interfaces, see [I2C](driver-platform-i2c-des.md#section5361140416). - I2C: Since only a small amount of touch data is reported by the touchscreen, I2C is used to transmit the reported data. For details about the I2C protocol and interfaces, see [I2C](driver-platform-i2c-des.md#section5361140416).
- SPI: In addition to touch reporting data coordinates, some vendors need to obtain basic capacitance data. Therefore, Serial Peripheral Interface \(SPI\) is used to transmit such huge amount of data. For details about the SPI protocol and interfaces, see [SPI](driver-platform-spi-des.md#section193356154511). - SPI: In addition to touch reporting data coordinates, some vendors need to obtain basic capacitance data. Therefore, Serial Peripheral Interface \(SPI\) is used to transmit such huge amount of data. For details about the SPI protocol and interfaces, see [SPI](driver-platform-spi-des.md#section193356154511).
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
## Overview<a name="section1"></a> ## Overview<a name="section1"></a>
- An analog-to-digital converter (ADC) is a device that converts analog signals into digital signals. An analog-to-digital converter (ADC) is a device that converts analog signals into digital signals.
- The ADC APIs provide a set of common functions for ADC data transfer, including: The ADC APIs provide a set of common functions for ADC data transfer, including:
- Opening or closing an ADC device - Opening or closing an ADC device
- Obtaining the analog-to-digital (AD) conversion result - Obtaining the analog-to-digital (AD) conversion result
**Figure 1** ADC physical connection<a name="fig1"></a> **Figure 1** ADC physical connection<a name="fig1"></a>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
The analog-to-digital converter \(ADC\) is a device that converts analog signals into digital signals. In the Hardware Driver Foundation \(HDF\), the ADC module uses the unified service mode for API adaptation. In this mode, a device service is used as the ADC manager to handle external access requests in a unified manner, which is reflected in the configuration file. The unified service mode applies to the scenario where there are many device objects of the same type, for example, when the ADC has more than 10 controllers. If the independent service mode is used, more device nodes need to be configured and memory resources will be consumed by services. The analog-to-digital converter \(ADC\) is a device that converts analog signals into digital signals. In the Hardware Driver Foundation \(HDF\), the ADC module uses the unified service mode for API adaptation. In this mode, a device service is used as the ADC manager to handle external access requests in a unified manner, which is reflected in the configuration file. The unified service mode applies to the scenario where there are many device objects of the same type, for example, when the ADC has more than 10 controllers. If the independent service mode is used, more device nodes need to be configured and memory resources will be consumed by services.
**Figure 1** Unified service mode<a name="fig14423182615525"></a> **Figure 1** Unified service mode<a name="fig14423182615525"></a>
![](figures/unified-service-mode.png "ADC-unified-service-mode") ![](figures/unified-service-mode.png "ADC-unified-service-mode")
## Available APIs<a name="section752964871810"></a> ## Available APIs<a name="section752964871810"></a>
...@@ -19,7 +19,7 @@ struct AdcMethod { ...@@ -19,7 +19,7 @@ struct AdcMethod {
}; };
``` ```
**Table 1** Callbacks for the members in the AdcMethod structure **Table 1** Callbacks for the members in the AdcMethod structure
<a name="table1943202316536"></a> <a name="table1943202316536"></a>
<table><thead align="left"><tr id="row2451223135315"><th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.1"><p id="p845123185313"><a name="p845123185313"></a><a name="p845123185313"></a>Callback</p> <table><thead align="left"><tr id="row2451223135315"><th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.1"><p id="p845123185313"><a name="p845123185313"></a><a name="p845123185313"></a>Callback</p>
...@@ -76,39 +76,36 @@ struct AdcMethod { ...@@ -76,39 +76,36 @@ struct AdcMethod {
The ADC module adaptation involves the following steps: The ADC module adaptation involves the following steps:
1. Instantiate the driver entry. 1. Instantiate the driver entry.
- Instantiate the **HdfDriverEntry** structure. - Instantiate the **HdfDriverEntry** structure.
- Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF. - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF.
2. Configure attribute files. 2. Configure attribute files.
- Add the **deviceNode** information to the **device\_info.hcs** file. - Add the **deviceNode** information to the **device\_info.hcs** file.
- \(Optional\) Add the **adc\_config.hcs** file. - \(Optional\) Add the **adc\_config.hcs** file.
3. Instantiate the ADC controller object. 3. Instantiate the ADC controller object.
- Initialize **AdcDevice**. - Initialize **AdcDevice**.
- Instantiate **AdcMethod** in the **AdcDevice** object. - Instantiate **AdcMethod** in the **AdcDevice** object.
>![](../public_sys-resources/icon-note.gif) **NOTE** For details, see [Available APIs](#available-apis).
>For details, see [Available APIs](#available-apis). 4. \(Optional\) Debug the driver.
For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether the signal collection is successful.
4. Debug the driver.
- \(Optional\) For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether the signal collection is successful.
## Development Example<a name="section1745221471165048"></a> ## Development Example<a name="section1745221471165048"></a>
The following uses **adc\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions. The following uses **adc\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions.
1. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. In the HDF, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke. 1. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. In the HDF, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke.
Generally, HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, HDF calls **Release** to release driver resources and exits. Generally, HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, HDF calls **Release** to release driver resources and exits.
- ADC driver entry reference - ADC driver entry reference
Many devices may connect to the ADC. In the HDF, a manager object needs to be created for the ADC. When a device needs to be started, the manager object locates the device based on the specified parameters. Many devices may connect to the ADC. In the HDF, a manager object needs to be created for the ADC. When a device needs to be started, the manager object locates the device based on the specified parameters.
The driver of the ADC manager is implemented by the core layer. Vendors do not need to pay attention to the implementation of this part. However, when they implement the **Init** function, the **AdcDeviceAdd** function of the core layer must be called to implement the corresponding features. The driver of the ADC manager is implemented by the core layer. Vendors do not need to pay attention to the implementation of this part. However, when they implement the **Init** function, the **AdcDeviceAdd** function of the core layer must be called to implement the corresponding features.
``` ```
static struct HdfDriverEntry g_hi35xxAdcDriverEntry = { static struct HdfDriverEntry g_hi35xxAdcDriverEntry = {
...@@ -129,9 +126,9 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha ...@@ -129,9 +126,9 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha
HDF_INIT(g_adcManagerEntry); HDF_INIT(g_adcManagerEntry);
``` ```
2. Add the **deviceNode** information to the **device\_info.hcs** file and configure the device attributes in the **adc\_config.hcs** file. The **deviceNode** information is related to registration of the driver entry. The device attribute values are closely related to the driver implementation and the default values or value ranges of the **AdcDevice** members at the core layer. 2. Add the **deviceNode** information to the **device\_info.hcs** file and configure the device attributes in the **adc\_config.hcs** file. The **deviceNode** information is related to registration of the driver entry. The device attribute values are closely related to the driver implementation and the default values or value ranges of the **AdcDevice** members at the core layer.
In the unified service mode, the first device node in the **device\_info** file must be the ADC manager, and the parameters must be set as follows: In the unified service mode, the first device node in the **device\_info** file must be the ADC manager, and the parameters must be set as follows:
<a name="table1344068233165048"></a> <a name="table1344068233165048"></a>
<table><thead align="left"><tr id="row1551612465165048"><th class="cellrowborder" valign="top" width="50%" id="mcps1.1.3.1.1"><p id="entry1856185125165048p0"><a name="entry1856185125165048p0"></a><a name="entry1856185125165048p0"></a>Member</p> <table><thead align="left"><tr id="row1551612465165048"><th class="cellrowborder" valign="top" width="50%" id="mcps1.1.3.1.1"><p id="entry1856185125165048p0"><a name="entry1856185125165048p0"></a><a name="entry1856185125165048p0"></a>Member</p>
...@@ -163,9 +160,9 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha ...@@ -163,9 +160,9 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha
</tbody> </tbody>
</table> </table>
Configure ADC controller information from the second node. This node specifies a type of ADC controllers rather than an ADC controller. In this example, there is only one ADC device. If there are multiple ADC devices, you need to add the **deviceNode** information to the **device\_info** file and add the corresponding device attributes to the **adc\_config** file. Configure ADC controller information from the second node. This node specifies a type of ADC controllers rather than an ADC controller. In this example, there is only one ADC device. If there are multiple ADC devices, you need to add the **deviceNode** information to the **device\_info** file and add the corresponding device attributes to the **adc\_config** file.
- **device\_info.hcs** configuration reference - **device\_info.hcs** configuration reference
``` ```
root { root {
...@@ -221,10 +218,10 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha ...@@ -221,10 +218,10 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha
} }
``` ```
3. Initialize the **AdcDevice** object at the core layer, including initializing the vendor custom structure \(transferring parameters and data\), instantiating **AdcMethod** \(used to call underlying functions of the driver\) in **AdcDevice**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\). 3. Initialize the **AdcDevice** object at the core layer, including initializing the vendor custom structure \(transferring parameters and data\), instantiating **AdcMethod** \(used to call underlying functions of the driver\) in **AdcDevice**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\).
- Custom structure reference - Custom structure reference
To the driver, the custom structure carries parameters and data. The values in the **adc\_config.hcs** file are read by HDF, and the structure members are initialized through **DeviceResourceIface**. Some important values, such as the device number and bus number, are also passed to the **AdcDevice** object at the core layer. To the driver, the custom structure carries parameters and data. The values in the **adc\_config.hcs** file are read by HDF, and the structure members are initialized through **DeviceResourceIface**. Some important values, such as the device number and bus number, are also passed to the **AdcDevice** object at the core layer.
``` ```
struct Hi35xxAdcDevice { struct Hi35xxAdcDevice {
...@@ -254,7 +251,7 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha ...@@ -254,7 +251,7 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha
}; };
``` ```
- Instantiate the callback function structure **AdcMethod** in **AdcDevice**. The **AdcLockMethod** callback function structure is not implemented in this example. To instantiate the structure, refer to the I2C driver development. Other members are initialized in the **Init** function. - Instantiate the callback function structure **AdcMethod** in **AdcDevice**. The **AdcLockMethod** callback function structure is not implemented in this example. To instantiate the structure, refer to the I2C driver development. Other members are initialized in the **Init** function.
``` ```
static const struct AdcMethod g_method = { static const struct AdcMethod g_method = {
...@@ -268,11 +265,11 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha ...@@ -268,11 +265,11 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values: Return values:
HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **//drivers/framework/include/utils/hdf\_base.h** file.\) HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **//drivers/framework/include/utils/hdf\_base.h** file.\)
<a name="table127573104165048"></a> <a name="table127573104165048"></a>
<table><thead align="left"><tr id="row1932243367165048"><th class="cellrowborder" valign="top" width="50%" id="mcps1.1.3.1.1"><p id="entry405408385165048p0"><a name="entry405408385165048p0"></a><a name="entry405408385165048p0"></a>Status (Value)</p> <table><thead align="left"><tr id="row1932243367165048"><th class="cellrowborder" valign="top" width="50%" id="mcps1.1.3.1.1"><p id="entry405408385165048p0"><a name="entry405408385165048p0"></a><a name="entry405408385165048p0"></a>Status (Value)</p>
...@@ -316,7 +313,7 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha ...@@ -316,7 +313,7 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha
Function description: Function description:
Initializes the custom structure object and **AdcDevice**, and calls the **AdcDeviceAdd** function at the core layer. Initializes the custom structure object and **AdcDevice**, and calls the **AdcDeviceAdd** function at the core layer.
``` ```
static int32_t Hi35xxAdcInit(struct HdfDeviceObject *device) static int32_t Hi35xxAdcInit(struct HdfDeviceObject *device)
...@@ -371,7 +368,7 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha ...@@ -371,7 +368,7 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values: Return values:
...@@ -379,7 +376,7 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha ...@@ -379,7 +376,7 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha
Function description: Function description:
Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the corresponding value assignment operations. Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the corresponding value assignment operations.
``` ```
static void Hi35xxAdcRelease(struct HdfDeviceObject *device) static void Hi35xxAdcRelease(struct HdfDeviceObject *device)
...@@ -414,7 +411,4 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha ...@@ -414,7 +411,4 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha
OsalMemFree(hi35xx); OsalMemFree(hi35xx);
} }
return return
``` ```
\ No newline at end of file
...@@ -42,7 +42,8 @@ The DAC module is divided into the following layers: ...@@ -42,7 +42,8 @@ The DAC module is divided into the following layers:
- The core layer provides the capabilities of binding, initializing, and releasing devices. - The core layer provides the capabilities of binding, initializing, and releasing devices.
- The adaptation layer implements other functions. - The adaptation layer implements other functions.
![](../public_sys-resources/icon-note.gif)NOTE<br/>The core layer can call the functions of the interface layer and uses the hook to call functions of the adaptation layer. In this way, the adaptation layer can indirectly call the functions of the interface layer, but the interface layer cannot call the functions of the adaptation layer. >![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>The core layer can call the functions of the interface layer and uses the hook to call functions of the adaptation layer. In this way, the adaptation layer can indirectly call the functions of the interface layer, but the interface layer cannot call the functions of the adaptation layer.
**Figure 1** Unified service mode **Figure 1** Unified service mode
...@@ -88,10 +89,10 @@ DevHandle DacOpen(uint32_t number); ...@@ -88,10 +89,10 @@ DevHandle DacOpen(uint32_t number);
**Table 2** Description of DacOpen **Table 2** Description of DacOpen
| **Parameter** | Description | | **Parameter** | Description |
| ---------- | ----------------- | | ---------- | ----------------- |
| number | DAC device number. | | number | DAC device number. |
| **Return Value**| **Description** | | **Return Value**| **Description** |
| NULL | Failed to open the DAC device. | | NULL | Failed to open the DAC device. |
| Device handle | Handle of the DAC device opened.| | Device handle | Handle of the DAC device opened.|
...@@ -119,7 +120,7 @@ int32_t DacWrite(DevHandle handle, uint32_t channel, uint32_t val); ...@@ -119,7 +120,7 @@ int32_t DacWrite(DevHandle handle, uint32_t channel, uint32_t val);
**Table 3** Description of DacWrite **Table 3** Description of DacWrite
| **Parameter** | Description | | **Parameter** | Description |
| ---------- | -------------- | | ---------- | -------------- |
| handle | DAC device handle. | | handle | DAC device handle. |
| channel | DAC channel number. | | channel | DAC channel number. |
...@@ -148,7 +149,7 @@ void DacClose(DevHandle handle); ...@@ -148,7 +149,7 @@ void DacClose(DevHandle handle);
**Table 4** Description of DacClose **Table 4** Description of DacClose
| **Parameter** | Description | | **Parameter** | Description |
| ---------- | -------------- | | ---------- | -------------- |
| handle | DAC device handle. | | handle | DAC device handle. |
| **Return Value**| **Description**| | **Return Value**| **Description**|
...@@ -208,4 +209,4 @@ static int32_t TestCaseDac(void) ...@@ -208,4 +209,4 @@ static int32_t TestCaseDac(void)
return 0; return 0;
} }
``` ```
\ No newline at end of file
...@@ -36,7 +36,8 @@ The DAC module is divided into the following layers: ...@@ -36,7 +36,8 @@ The DAC module is divided into the following layers:
- The core layer provides the capabilities of binding, initializing, and releasing devices. - The core layer provides the capabilities of binding, initializing, and releasing devices.
- The adaptation layer implements other functions. - The adaptation layer implements other functions.
![](../public_sys-resources/icon-note.gif)NOTE<br/>The core layer can call the functions of the interface layer and uses the hook to call functions of the adaptation layer. In this way, the adaptation layer can indirectly call the functions of the interface layer, but the interface layer cannot call the functions of the adaptation layer. >![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>The core layer can call the functions of the interface layer and uses the hook to call functions of the adaptation layer. In this way, the adaptation layer can indirectly call the functions of the interface layer, but the interface layer cannot call the functions of the adaptation layer.
**Figure 1** Unified service mode<a name="fig14423182615525"></a> **Figure 1** Unified service mode<a name="fig14423182615525"></a>
...@@ -129,7 +130,7 @@ The DAC module adaptation procedure is as follows: ...@@ -129,7 +130,7 @@ The DAC module adaptation procedure is as follows:
Configure DAC controller information from the second node. This node specifies a type of DAC controllers rather than a specific DAC controller. In this example, there is only one DAC device. If there are multiple DAC devices, you need to add the **deviceNode** information to the **device_info** file and add the corresponding device attributes to the **dac_config** file. Configure DAC controller information from the second node. This node specifies a type of DAC controllers rather than a specific DAC controller. In this example, there is only one DAC device. If there are multiple DAC devices, you need to add the **deviceNode** information to the **device_info** file and add the corresponding device attributes to the **dac_config** file.
**device_info.hcs** configuration reference **device_info.hcs** configuration reference
``` ```
root { root {
...@@ -283,15 +284,15 @@ The DAC module adaptation procedure is as follows: ...@@ -283,15 +284,15 @@ The DAC module adaptation procedure is as follows:
}; };
``` ```
![](../public_sys-resources/icon-note.gif) **NOTE**<br/> >![](../public_sys-resources/icon-note.gif) **NOTE**<br>
For details about **DacMethod**, see [Available APIs](#available-apis). >For details about **DacMethod**, see [Available APIs](#available-apis).
- **Init** function - **Init** function
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return value: Return value:
...@@ -388,11 +389,11 @@ The DAC module adaptation procedure is as follows: ...@@ -388,11 +389,11 @@ The DAC module adaptation procedure is as follows:
} }
``` ```
- **Release** function - **Release** function
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return value Return value
...@@ -465,6 +466,4 @@ The DAC module adaptation procedure is as follows: ...@@ -465,6 +466,4 @@ The DAC module adaptation procedure is as follows:
4. Debug the driver. 4. Debug the driver.
(Optional) Verify the basic functions of the new driver, for example, whether the test cases are successful after the driver is loaded. (Optional) Verify the basic functions of the new driver, for example, whether the test cases are successful after the driver is loaded.
\ No newline at end of file
...@@ -15,7 +15,7 @@ The GPIO APIs define a set of standard functions for performing operations on GP ...@@ -15,7 +15,7 @@ The GPIO APIs define a set of standard functions for performing operations on GP
## Available APIs<a name="section589913442203"></a> ## Available APIs<a name="section589913442203"></a>
**Table 1** APIs available for the GPIO driver **Table 1** APIs available for the GPIO driver
<a name="table89681075215"></a> <a name="table89681075215"></a>
<table><thead align="left"><tr id="row996807162115"><th class="cellrowborder" valign="top" width="19.74%" id="mcps1.2.4.1.1"><p id="p296817716212"><a name="p296817716212"></a><a name="p296817716212"></a>Capability</p> <table><thead align="left"><tr id="row996807162115"><th class="cellrowborder" valign="top" width="19.74%" id="mcps1.2.4.1.1"><p id="p296817716212"><a name="p296817716212"></a><a name="p296817716212"></a>Capability</p>
...@@ -75,16 +75,16 @@ The GPIO APIs define a set of standard functions for performing operations on GP ...@@ -75,16 +75,16 @@ The GPIO APIs define a set of standard functions for performing operations on GP
</tbody> </tbody>
</table> </table>
>![](../public_sys-resources/icon-note.gif) **NOTE:** >![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>All functions provided in this document can be called only in kernel mode. >All functions provided in this document can be called only in kernel mode.
## Usage Guidelines<a name="section259614242196"></a> ## Usage Guidelines<a name="section259614242196"></a>
### How to Use<a name="section103477714216"></a> ### How to Use<a name="section103477714216"></a>
The GPIO APIs use the GPIO pin number to specify a pin. [Figure 1](#fig16151101653713) shows the general process of using a GPIO. The GPIO APIs use the GPIO pin number to specify a pin. [Figure 1](#fig16151101653713) shows the general process of using a GPIO.
**Figure 1** Process of using a GPIO<a name="fig16151101653713"></a> **Figure 1** Process of using a GPIO<a name="fig16151101653713"></a>
![](figures/process-of-using-a-gpio.png "process-of-using-a-gpio") ![](figures/process-of-using-a-gpio.png "process-of-using-a-gpio")
### Determining a GPIO Pin Number<a name="section370083272117"></a> ### Determining a GPIO Pin Number<a name="section370083272117"></a>
...@@ -116,7 +116,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -116,7 +116,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
int32\_t GpioSetDir\(uint16\_t gpio, uint16\_t dir\); int32\_t GpioSetDir\(uint16\_t gpio, uint16\_t dir\);
**Table 2** Description of GpioSetDir **Table 2** Description of GpioSetDir
<a name="table63111557616"></a> <a name="table63111557616"></a>
<table><tbody><tr id="row17311165469"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p53110515616"><a name="p53110515616"></a><a name="p53110515616"></a><strong id="b1142022718160"><a name="b1142022718160"></a><a name="b1142022718160"></a>Parameter</strong></p> <table><tbody><tr id="row17311165469"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p53110515616"><a name="p53110515616"></a><a name="p53110515616"></a><strong id="b1142022718160"><a name="b1142022718160"></a><a name="b1142022718160"></a>Parameter</strong></p>
...@@ -159,7 +159,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -159,7 +159,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
int32\_t GpioRead\(uint16\_t gpio, uint16\_t \*val\); int32\_t GpioRead\(uint16\_t gpio, uint16\_t \*val\);
**Table 3** Description of GpioRead **Table 3** Description of GpioRead
<a name="table20347743174816"></a> <a name="table20347743174816"></a>
<table><tbody><tr id="row17348144394816"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p19348164313481"><a name="p19348164313481"></a><a name="p19348164313481"></a><strong id="b4862227121610"><a name="b4862227121610"></a><a name="b4862227121610"></a>Parameter</strong></p> <table><tbody><tr id="row17348144394816"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p19348164313481"><a name="p19348164313481"></a><a name="p19348164313481"></a><strong id="b4862227121610"><a name="b4862227121610"></a><a name="b4862227121610"></a>Parameter</strong></p>
...@@ -199,7 +199,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -199,7 +199,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
int32\_t GpioWrite\(uint16\_t gpio, uint16\_t val\); int32\_t GpioWrite\(uint16\_t gpio, uint16\_t val\);
**Table 4** Description of GpioWrite **Table 4** Description of GpioWrite
<a name="table1214911207520"></a> <a name="table1214911207520"></a>
<table><tbody><tr id="row6149720175218"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p18149132005216"><a name="p18149132005216"></a><a name="p18149132005216"></a><strong id="b19864427181615"><a name="b19864427181615"></a><a name="b19864427181615"></a>Parameter</strong></p> <table><tbody><tr id="row6149720175218"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p18149132005216"><a name="p18149132005216"></a><a name="p18149132005216"></a><strong id="b19864427181615"><a name="b19864427181615"></a><a name="b19864427181615"></a>Parameter</strong></p>
...@@ -269,7 +269,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -269,7 +269,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
int32\_t GpioSetIrq\(uint16\_t gpio, uint16\_t mode, GpioIrqFunc func, void \*arg\); int32\_t GpioSetIrq\(uint16\_t gpio, uint16\_t mode, GpioIrqFunc func, void \*arg\);
**Table 5** Description of GpioSetIrq **Table 5** Description of GpioSetIrq
<a name="table16804111812466"></a> <a name="table16804111812466"></a>
<table><tbody><tr id="row880401834615"><td class="cellrowborder" valign="top" width="48.54%"><p id="p380491819469"><a name="p380491819469"></a><a name="p380491819469"></a><strong id="b0865192761614"><a name="b0865192761614"></a><a name="b0865192761614"></a>Parameter</strong></p> <table><tbody><tr id="row880401834615"><td class="cellrowborder" valign="top" width="48.54%"><p id="p380491819469"><a name="p380491819469"></a><a name="p380491819469"></a><strong id="b0865192761614"><a name="b0865192761614"></a><a name="b0865192761614"></a>Parameter</strong></p>
...@@ -316,13 +316,13 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -316,13 +316,13 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
</table> </table>
>![](../public_sys-resources/icon-caution.gif) **CAUTION:** >![](../public_sys-resources/icon-caution.gif) **CAUTION:**
>Only one ISR function can be set for a GPIO pin at a time. If **GpioSetIrq** is called repeatedly, the previous IRS function will be replaced. >Only one ISR function can be set for a GPIO pin at a time. If **GpioSetIrq** is called repeatedly, the previous IRS function will be replaced.
If the ISR function is no longer required, call the following function to cancel the setting: If the ISR function is no longer required, call the following function to cancel the setting:
int32\_t GpioUnSetIrq\(uint16\_t gpio\); int32\_t GpioUnSetIrq\(uint16\_t gpio\);
**Table 6** Description of GpioUnSetIrq **Table 6** Description of GpioUnSetIrq
<a name="table1157224664316"></a> <a name="table1157224664316"></a>
<table><tbody><tr id="row175721546174317"><td class="cellrowborder" valign="top" width="48.54%"><p id="p16572144694311"><a name="p16572144694311"></a><a name="p16572144694311"></a><strong id="b16866132761617"><a name="b16866132761617"></a><a name="b16866132761617"></a>Parameter</strong></p> <table><tbody><tr id="row175721546174317"><td class="cellrowborder" valign="top" width="48.54%"><p id="p16572144694311"><a name="p16572144694311"></a><a name="p16572144694311"></a><strong id="b16866132761617"><a name="b16866132761617"></a><a name="b16866132761617"></a>Parameter</strong></p>
...@@ -357,7 +357,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -357,7 +357,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
int32\_t GpioEnableIrq\(uint16\_t gpio\); int32\_t GpioEnableIrq\(uint16\_t gpio\);
**Table 7** Description of GpioEnableIrq **Table 7** Description of GpioEnableIrq
<a name="table26659291568"></a> <a name="table26659291568"></a>
<table><tbody><tr id="row866632919566"><td class="cellrowborder" valign="top" width="50%"><p id="p066642985615"><a name="p066642985615"></a><a name="p066642985615"></a><strong id="b108661927171614"><a name="b108661927171614"></a><a name="b108661927171614"></a>Parameter</strong></p> <table><tbody><tr id="row866632919566"><td class="cellrowborder" valign="top" width="50%"><p id="p066642985615"><a name="p066642985615"></a><a name="p066642985615"></a><strong id="b108661927171614"><a name="b108661927171614"></a><a name="b108661927171614"></a>Parameter</strong></p>
...@@ -395,7 +395,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -395,7 +395,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
int32\_t GpioDisableIrq\(uint16\_t gpio\); int32\_t GpioDisableIrq\(uint16\_t gpio\);
**Table 8** Description of GpioDisableIrq **Table 8** Description of GpioDisableIrq
<a name="table186682041918"></a> <a name="table186682041918"></a>
<table><tbody><tr id="row186684413116"><td class="cellrowborder" valign="top" width="50%"><p id="p866844916"><a name="p866844916"></a><a name="p866844916"></a><strong id="b88678273169"><a name="b88678273169"></a><a name="b88678273169"></a>Parameter</strong></p> <table><tbody><tr id="row186684413116"><td class="cellrowborder" valign="top" width="50%"><p id="p866844916"><a name="p866844916"></a><a name="p866844916"></a><strong id="b88678273169"><a name="b88678273169"></a><a name="b88678273169"></a>Parameter</strong></p>
...@@ -545,5 +545,4 @@ static int32_t TestCaseGpioIrqEdge(void) ...@@ -545,5 +545,4 @@ static int32_t TestCaseGpioIrqEdge(void)
(void)GpioUnSetIrq(gpio); (void)GpioUnSetIrq(gpio);
return (g_irqCnt > 0) ? HDF_SUCCESS : HDF_FAILURE; return (g_irqCnt > 0) ? HDF_SUCCESS : HDF_FAILURE;
} }
``` ```
\ No newline at end of file
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
## Overview<a name="section1826197354103451"></a> ## Overview<a name="section1826197354103451"></a>
In the Hardware Driver Foundation \(HDF\) framework, the general-purpose input/output \(GPIO\) module uses the service-free mode for API adaptation. The service-free mode applies to the devices that do not provide user-mode APIs or the OS system that does not distinguish the user mode and the kernel mode. In the service-free mode, **DevHandle** \(a void pointer\) directly points to the kernel-mode address of the device object. In the Hardware Driver Foundation \(HDF\) framework, the general-purpose input/output \(GPIO\) module uses the service-free mode for API adaptation. The service-free mode applies to the devices that do not provide user-mode APIs or the OS system that does not distinguish the user mode and the kernel mode. In the service-free mode, **DevHandle** \(a void pointer\) directly points to the kernel-mode address of the device object.
**Figure 1** Service-free mode<a name="fig5511033193814"></a> **Figure 1** Service-free mode<a name="fig5511033193814"></a>
![](figures/service-free-mode.png "service-free-mode") ![](figures/service-free-mode.png "service-free-mode")
## Available APIs<a name="section752964871810"></a> ## Available APIs<a name="section752964871810"></a>
...@@ -26,7 +26,7 @@ struct GpioMethod { ...@@ -26,7 +26,7 @@ struct GpioMethod {
int32_t (*disableIrq)(struct GpioCntlr *cntlr, uint16_t local); int32_t (*disableIrq)(struct GpioCntlr *cntlr, uint16_t local);
} }
``` ```
**Table 1** Callbacks for the members in the GpioMethod structure **Table 1** Callbacks for the members in the GpioMethod structure
<a name="table151341544111"></a> <a name="table151341544111"></a>
<table><thead align="left"><tr id="row19514101504111"><th class="cellrowborder" align="center" valign="top" width="20%" id="mcps1.2.6.1.1"><p id="p451461513418"><a name="p451461513418"></a><a name="p451461513418"></a>Callback</p> <table><thead align="left"><tr id="row19514101504111"><th class="cellrowborder" align="center" valign="top" width="20%" id="mcps1.2.6.1.1"><p id="p451461513418"><a name="p451461513418"></a><a name="p451461513418"></a>Callback</p>
...@@ -152,32 +152,30 @@ The GPIO controller manages all pins by group. The related parameters are descri ...@@ -152,32 +152,30 @@ The GPIO controller manages all pins by group. The related parameters are descri
The GPIO module adaptation involves the following steps: The GPIO module adaptation involves the following steps:
1. Instantiate the driver entry. 1. Instantiate the driver entry.
- Instantiate the **HdfDriverEntry** structure. - Instantiate the **HdfDriverEntry** structure.
- Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework. - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework.
2. Configure attribute files. 2. Configure attribute files.
- Add the **deviceNode** information to the **device\_info.hcs** file. - Add the **deviceNode** information to the **device\_info.hcs** file.
- \(Optional\) Add the **gpio\_config.hcs** file. - \(Optional\) Add the **gpio\_config.hcs** file.
3. Instantiate the GPIO controller object. 3. Instantiate the GPIO controller object.
- Initialize **GpioCntlr**. - Initialize **GpioCntlr**.
- Instantiate **GpioMethod** in the **GpioCntlr** object. - Instantiate **GpioMethod** in the **GpioCntlr** object.
>![](../public_sys-resources/icon-note.gif) **NOTE:** For details, see [Available APIs](#section752964871810).
>For details, see [Available APIs](#section752964871810).
4. Debug the driver. 4. \(Optional\) Debug the driver.
- \(Optional\) For new drivers, verify the basic functions, such as the GPIO control status and response to interrupts. For new drivers, verify the basic functions, such as the GPIO control status and response to interrupts.
## Development Example<a name="section800425816103451"></a> ## Development Example<a name="section800425816103451"></a>
The following uses **gpio\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions. The following uses **gpio\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions.
1. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. In the HDF framework, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke. 1. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. In the HDF framework, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke.
Generally, HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, HDF calls **Release** to release driver resources and exits. Generally, HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, HDF calls **Release** to release driver resources and exits.
- GPIO driver entry reference - GPIO driver entry reference
...@@ -193,11 +191,11 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th ...@@ -193,11 +191,11 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th
HDF_INIT(g_gpioDriverEntry); HDF_INIT(g_gpioDriverEntry);
``` ```
2. Add the **deviceNode** information to the **device\_info.hcs** file and configure the device attributes in the **gpio\_config.hcs** file. The **deviceNode** information is related to registration of the driver entry. The device attribute values are closely related to the default values or value ranges of the **GpioCntlr** members at the core layer. 2. Add the **deviceNode** information to the **device\_info.hcs** file and configure the device attributes in the **gpio\_config.hcs** file. The **deviceNode** information is related to registration of the driver entry. The device attribute values are closely related to the default values or value ranges of the **GpioCntlr** members at the core layer.
In this example, there is only one GPIO controller. If there are multiple GPIO controllers, you need to add the **deviceNode** information to the **device\_info** file and add the corresponding device attributes to the **gpio\_config** file. In this example, there is only one GPIO controller. If there are multiple GPIO controllers, you need to add the **deviceNode** information to the **device\_info** file and add the corresponding device attributes to the **gpio\_config** file.
- **device\_info.hcs** configuration reference - **device\_info.hcs** configuration reference
``` ```
root { root {
...@@ -220,7 +218,7 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th ...@@ -220,7 +218,7 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th
} }
``` ```
- **gpio\_config.hcs** configuration reference - **gpio\_config.hcs** configuration reference
``` ```
root { root {
...@@ -240,10 +238,10 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th ...@@ -240,10 +238,10 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th
} }
``` ```
3. Initialize the **GpioCntlr** object at the core layer, including initializing the vendor custom structure \(transferring parameters and data\), instantiating **GpioMethod** \(used to call underlying functions of the driver\) in **GpioCntlr**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\). 3. Initialize the **GpioCntlr** object at the core layer, including initializing the vendor custom structure \(transferring parameters and data\), instantiating **GpioMethod** \(used to call underlying functions of the driver\) in **GpioCntlr**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\).
- Custom structure reference - Custom structure reference
To the driver, the custom structure carries parameters and data. The values in the **gpio\_config.hcs** file are read by HDF, and the structure members are initialized through **DeviceResourceIface**. Some important values, such as the index and the number of pins, are also passed to the **GpioCntlr** object at the core layer. To the driver, the custom structure carries parameters and data. The values in the **gpio\_config.hcs** file are read by HDF, and the structure members are initialized through **DeviceResourceIface**. Some important values, such as the index and the number of pins, are also passed to the **GpioCntlr** object at the core layer.
``` ```
struct Pl061GpioCntlr { struct Pl061GpioCntlr {
...@@ -279,7 +277,7 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th ...@@ -279,7 +277,7 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th
}; };
``` ```
- Instantiate the callback function structure **GpioMethod** in **GpioCntlr**. Other members are initialized by using the **Init** function. - Instantiate the callback function structure **GpioMethod** in **GpioCntlr**. Other members are initialized by using the **Init** function.
``` ```
// The members of the GpioMethod structure are all callbacks. Vendors need to implement the corresponding functions according to [Table 1](#table151341544111). // The members of the GpioMethod structure are all callbacks. Vendors need to implement the corresponding functions according to [Table 1](#table151341544111).
...@@ -304,13 +302,13 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th ...@@ -304,13 +302,13 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values: Return values:
HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **//drivers/framework/include/utils/hdf\_base.h** file.\) HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **//drivers/framework/include/utils/hdf\_base.h** file.\)
**Table 2** Init function description **Table 2** Init function description
<a name="table165981547354"></a> <a name="table165981547354"></a>
<table><thead align="left"><tr id="row8599145423516"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p959995453515"><a name="p959995453515"></a><a name="p959995453515"></a>Status (Value)</p> <table><thead align="left"><tr id="row8599145423516"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p959995453515"><a name="p959995453515"></a><a name="p959995453515"></a>Status (Value)</p>
...@@ -354,7 +352,7 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th ...@@ -354,7 +352,7 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th
Function description: Function description:
Initializes the custom structure object and **GpioCntlr**, calls the **GpioCntlrAdd** function at the core layer, and connects to the VFS \(optional\). Initializes the custom structure object and **GpioCntlr**, calls the **GpioCntlrAdd** function at the core layer, and connects to the VFS \(optional\).
``` ```
static int32_t Pl061GpioInit(struct HdfDeviceObject *device) static int32_t Pl061GpioInit(struct HdfDeviceObject *device)
...@@ -392,7 +390,7 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th ...@@ -392,7 +390,7 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values: Return values:
...@@ -400,7 +398,7 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th ...@@ -400,7 +398,7 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th
Function description: Function description:
Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF framework fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the corresponding value assignment operations. Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF framework fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the corresponding value assignment operations.
``` ```
...@@ -421,8 +419,4 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th ...@@ -421,8 +419,4 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th
OsalIoUnmap((void *)pl061->regBase);// (Mandatory) Remove the address mapping. OsalIoUnmap((void *)pl061->regBase);// (Mandatory) Remove the address mapping.
pl061->regBase = NULL; pl061->regBase = NULL;
} }
``` ```
\ No newline at end of file
...@@ -5,15 +5,15 @@ ...@@ -5,15 +5,15 @@
### HDMI ### HDMI
- High-definition multimedia interface (HDMI) is an interface for transmitting audio and video data from a source device, such as a DVD player or set-top box (STB), to a sink device, such as a TV or display. High-definition multimedia interface (HDMI) is an interface for transmitting audio and video data from a source device, such as a DVD player or set-top box (STB), to a sink device, such as a TV or display.
- HDMI works in master/slave mode and usually has a source and a sink. HDMI works in primary/secondary mode and usually has a source and a sink.
- The HDMI APIs provide a set of common functions for HDMI transmission, including: The HDMI APIs provide a set of common functions for HDMI transmission, including:
- Opening and closing an HDMI controller - Opening and closing an HDMI controller
- Starting and stopping HDMI transmission - Starting and stopping HDMI transmission
- Setting audio, video, and High Dynamic Range (HDR) attributes, color depth, and AV mute - Setting audio, video, and High Dynamic Range (HDR) attributes, color depth, and AV mute
- Reading the raw Extended Display Identification Data (EDID) from a sink - Reading the raw Extended Display Identification Data (EDID) from a sink
- Registering and unregistering a callback for HDMI hot plug detect (HPD). - Registering and unregistering a callback for HDMI hot plug detect (HPD).
### Basic Concepts ### Basic Concepts
...@@ -88,7 +88,7 @@ DevHandle HdmiOpen(int16_t number); ...@@ -88,7 +88,7 @@ DevHandle HdmiOpen(int16_t number);
| Parameter | Description | | Parameter | Description |
| ---------- | -------------------- | | ---------- | -------------------- |
| number | HDMI controller ID. | | number | HDMI controller ID. |
| **Return Value**| **Description** | | **Return Value**| **Description** |
| NULL | Failed to open the HDMI controller. | | NULL | Failed to open the HDMI controller. |
| Controller handle| Handle of the opened HDMI controller.| | Controller handle| Handle of the opened HDMI controller.|
...@@ -117,7 +117,7 @@ int32_t HdmiRegisterHpdCallbackFunc(DevHandle handle, struct HdmiHpdCallbackInfo ...@@ -117,7 +117,7 @@ int32_t HdmiRegisterHpdCallbackFunc(DevHandle handle, struct HdmiHpdCallbackInfo
| ---------- | ------------------ | | ---------- | ------------------ |
| handle | HDMI controller handle. | | handle | HDMI controller handle. |
| callback | Pointer to the callback to be invoked to return the HPD result.| | callback | Pointer to the callback to be invoked to return the HPD result.|
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful. | | 0 | The operation is successful. |
| Negative value | The operation failed. | | Negative value | The operation failed. |
...@@ -165,7 +165,7 @@ int32_t HdmiReadSinkEdid(DevHandle handle, uint8_t *buffer, uint32_t len); ...@@ -165,7 +165,7 @@ int32_t HdmiReadSinkEdid(DevHandle handle, uint8_t *buffer, uint32_t len);
| handle | HDMI controller handle. | | handle | HDMI controller handle. |
| buffer | Pointer to the data buffer. | | buffer | Pointer to the data buffer. |
| len | Data length. | | len | Data length. |
| **Return Value**| **Description** | | **Return Value**| **Description** |
| Positive integer | Raw EDID read.| | Positive integer | Raw EDID read.|
| Negative number or 0 | Failed to read the EDID. | | Negative number or 0 | Failed to read the EDID. |
...@@ -194,7 +194,7 @@ int32_t HdmiSetAudioAttribute(DevHandle handle, struct HdmiAudioAttr *attr); ...@@ -194,7 +194,7 @@ int32_t HdmiSetAudioAttribute(DevHandle handle, struct HdmiAudioAttr *attr);
| ------ | -------------- | | ------ | -------------- |
| handle | HDMI controller handle.| | handle | HDMI controller handle.|
| attr | Pointer to the audio attributes. | | attr | Pointer to the audio attributes. |
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful. | | 0 | The operation is successful. |
| Negative value | The operation failed. | | Negative value | The operation failed. |
...@@ -295,7 +295,7 @@ int32_t HdmiAvmuteSet(DevHandle handle, bool enable); ...@@ -295,7 +295,7 @@ int32_t HdmiAvmuteSet(DevHandle handle, bool enable);
| ---------- | ----------------- | | ---------- | ----------------- |
| handle | HDMI controller handle. | | handle | HDMI controller handle. |
| enable | Whether to enable the AV mute feature.| | enable | Whether to enable the AV mute feature.|
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful. | | 0 | The operation is successful. |
| Negative value | The operation failed. | | Negative value | The operation failed. |
...@@ -615,4 +615,4 @@ static int32_t TestCaseHdmi(void) ...@@ -615,4 +615,4 @@ static int32_t TestCaseHdmi(void)
return 0; return 0;
} }
``` ```
\ No newline at end of file
...@@ -40,7 +40,7 @@ Currently, the HDMI module supports only the kernels (LiteOS) of mini and small ...@@ -40,7 +40,7 @@ Currently, the HDMI module supports only the kernels (LiteOS) of mini and small
HDMI features high transmission rate, wide transmission bandwidth, high compatibility, and can transmit uncompressed audio and video signals. Compared with the traditional full analog interface, HDMI simplifies connection between devices and provides HDMI-specific intelligent features, which are ideal for high-quality audio and video transmission of small-sized devices. HDMI features high transmission rate, wide transmission bandwidth, high compatibility, and can transmit uncompressed audio and video signals. Compared with the traditional full analog interface, HDMI simplifies connection between devices and provides HDMI-specific intelligent features, which are ideal for high-quality audio and video transmission of small-sized devices.
### Available APIs ### Available APIs
**HdmiCntlrOps**: **HdmiCntlrOps**:
```c ```c
struct HdmiCntlrOps { struct HdmiCntlrOps {
...@@ -149,7 +149,7 @@ The HDMI module adaptation involves the following steps: ...@@ -149,7 +149,7 @@ The HDMI module adaptation involves the following steps:
.Bind = HdmiAdapterBind, .Bind = HdmiAdapterBind,
.Init = HdmiAdapterInit, .Init = HdmiAdapterInit,
.Release = HdmiAdapterRelease, .Release = HdmiAdapterRelease,
.moduleName = "adapter_hdmi_driver",// (mandatory) The value must be the same as that in the .hcs file. .moduleName = "adapter_hdmi_driver",// (Mandatory) The value must be the same as that in the .hcs file.
}; };
HDF_INIT(g_hdmiDriverEntry); // Call HDF_INIT to register the driver entry with the HDF. HDF_INIT(g_hdmiDriverEntry); // Call HDF_INIT to register the driver entry with the HDF.
``` ```
...@@ -315,11 +315,11 @@ The HDMI module adaptation involves the following steps: ...@@ -315,11 +315,11 @@ The HDMI module adaptation involves the following steps:
- **Bind()** function - **Bind()** function
**Input parameter**: **Input parameter**:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration.
**Return value**: **Return value**:
**HDF\_STATUS** (The following table lists some states. For more details, see **HDF\_STATUS** definition in the **/drivers/framework/include/utils/hdf\_base.h file**.) **HDF\_STATUS** (The following table lists some states. For more details, see **HDF\_STATUS** definition in the **/drivers/framework/include/utils/hdf\_base.h file**.)
| State | Description | | State | Description |
|:-|:-| |:-|:-|
...@@ -330,7 +330,7 @@ The HDMI module adaptation involves the following steps: ...@@ -330,7 +330,7 @@ The HDMI module adaptation involves the following steps:
|HDF_SUCCESS |Transmission successful.| |HDF_SUCCESS |Transmission successful.|
|HDF_FAILURE |Transmission failed.| |HDF_FAILURE |Transmission failed.|
**Function description**: **Function description**:
Initializes the custom structure object **HdmiAdapterHost** and **HdmiCntlr**, and calls the **HdmiCntlrAdd** function to add the HDMI controller to the core layer. Initializes the custom structure object **HdmiAdapterHost** and **HdmiCntlr**, and calls the **HdmiCntlrAdd** function to add the HDMI controller to the core layer.
The **HdmiCntlr**, **HdmiAdapterHost**, and **HdfDeviceObject** assign values with each other so that other functions can be converted successfully. The **HdmiCntlr**, **HdmiAdapterHost**, and **HdfDeviceObject** assign values with each other so that other functions can be converted successfully.
...@@ -374,13 +374,13 @@ The HDMI module adaptation involves the following steps: ...@@ -374,13 +374,13 @@ The HDMI module adaptation involves the following steps:
- **Init()** function - **Init()** function
**Input parameter**: **Input parameter**:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration.
**Return value**: **Return value**:
HDF_STATUS HDF_STATUS
**Function description**: **Function description**:
Implements the **HdmiAdapterInit** function. Implements the **HdmiAdapterInit** function.
...@@ -393,13 +393,13 @@ The HDMI module adaptation involves the following steps: ...@@ -393,13 +393,13 @@ The HDMI module adaptation involves the following steps:
- **Release()** function - **Release()** function
**Input parameter**: **Input parameter**:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration.
**Return value**: **Return value**:
**Function description**: **Function description**:
Releases the memory and deletes the controller. This function assigns a value to the **Release()** API in the driver entry structure. If the HDF fails to call the **Init()** function to initialize the driver, the **Release()** function can be called to release driver resources. Releases the memory and deletes the controller. This function assigns a value to the **Release()** API in the driver entry structure. If the HDF fails to call the **Init()** function to initialize the driver, the **Release()** function can be called to release driver resources.
```c ```c
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
The Inter-Integrated Circuit \(I2C\) bus is a simple and bidirectional two-wire synchronous serial bus developed by Philips. In the Hardware Driver Foundation (HDF) framework, the I2C module uses the unified service mode for API adaptation. In this mode, a device service is used as the I2C manager to handle external access requests in a unified manner, which is reflected in the configuration file. The unified service mode applies to the scenario where there are many device objects of the same type, for example, when the I2C module has more than 10 controllers. If the independent service mode is used, more device nodes need to be configured and memory resources will be consumed by services. The Inter-Integrated Circuit \(I2C\) bus is a simple and bidirectional two-wire synchronous serial bus developed by Philips. In the Hardware Driver Foundation (HDF) framework, the I2C module uses the unified service mode for API adaptation. In this mode, a device service is used as the I2C manager to handle external access requests in a unified manner, which is reflected in the configuration file. The unified service mode applies to the scenario where there are many device objects of the same type, for example, when the I2C module has more than 10 controllers. If the independent service mode is used, more device nodes need to be configured and memory resources will be consumed by services.
**Figure 1** Unified service mode<a name="fig17640124912440"></a> **Figure 1** Unified service mode<a name="fig17640124912440"></a>
![](figures/unified-service-mode.png "unified-service-mode-8") ![](figures/unified-service-mode.png "unified-service-mode-8")
## Available APIs<a name="section752964871810"></a> ## Available APIs<a name="section752964871810"></a>
...@@ -23,7 +23,7 @@ struct I2cLockMethod {// Lock mechanism operation structure ...@@ -23,7 +23,7 @@ struct I2cLockMethod {// Lock mechanism operation structure
}; };
``` ```
**Table 1** Callbacks for the members in the I2cMethod structure **Table 1** Callbacks for the members in the I2cMethod structure
<a name="table10549174014611"></a> <a name="table10549174014611"></a>
<table><thead align="left"><tr id="row17550114013460"><th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.1"><p id="p155014403467"><a name="p155014403467"></a><a name="p155014403467"></a>Callback</p> <table><thead align="left"><tr id="row17550114013460"><th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.1"><p id="p155014403467"><a name="p155014403467"></a><a name="p155014403467"></a>Callback</p>
...@@ -57,41 +57,39 @@ struct I2cLockMethod {// Lock mechanism operation structure ...@@ -57,41 +57,39 @@ struct I2cLockMethod {// Lock mechanism operation structure
The I2C module adaptation involves the following steps: The I2C module adaptation involves the following steps:
1. Instantiate the driver entry. 1. Instantiate the driver entry.
- Instantiate the **HdfDriverEntry** structure. - Instantiate the **HdfDriverEntry** structure.
- Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework. - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework.
2. Configure attribute files. 2. Configure attribute files.
- Add the **deviceNode** information to the **device\_info.hcs** file. - Add the **deviceNode** information to the **device\_info.hcs** file.
- \(Optional\) Add the **i2c\_config.hcs** file. - \(Optional\) Add the **i2c\_config.hcs** file.
3. Instantiate the I2C controller object. 3. Instantiate the I2C controller object.
- Initialize **I2cCntlr**. - Initialize **I2cCntlr**.
- Instantiate **I2cMethod** and **I2cLockMethod** in **I2cCntlr**. - Instantiate **I2cMethod** and **I2cLockMethod** in **I2cCntlr**.
>![](../public_sys-resources/icon-note.gif) **NOTE** For details, see [Available APIs](#available-apis).
4. \(Optional\) Debug the driver.
>For details, see [Available APIs](#available-apis). For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether data is successfully transmitted.
4. Debug the driver.
- \(Optional\) For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether data is successfully transmitted.
## Development Example<a name="section1773332551114257"></a> ## Development Example<a name="section1773332551114257"></a>
The following uses **i2c\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions. The following uses **i2c\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions.
1. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. In the HDF framework, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke. 1. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. In the HDF framework, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke.
Generally, HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, HDF calls **Release** to release driver resources and exit. Generally, HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, HDF calls **Release** to release driver resources and exit.
- I2C driver entry reference - I2C driver entry reference
Many devices may be connected to the I2C module. Therefore, in the HDF framework, a manager object is created for the I2C, and a manager service is launched to handle external access requests in a unified manner. When a user wants to open a device, the user obtains the manager service first. Then, the manager service locates the target device based on the parameters specified by the user. Many devices may be connected to the I2C module. Therefore, in the HDF framework, a manager object is created for the I2C, and a manager service is launched to handle external access requests in a unified manner. When a user wants to open a device, the user obtains the manager service first. Then, the manager service locates the target device based on the parameters specified by the user.
The driver of the I2C manager is implemented by the core layer. Vendors do not need to pay attention to the implementation of this part. However, when they implement the **Init** function, the **I2cCntlrAdd** function of the core layer must be called to implement the corresponding features. The driver of the I2C manager is implemented by the core layer. Vendors do not need to pay attention to the implementation of this part. However, when they implement the **Init** function, the **I2cCntlrAdd** function of the core layer must be called to implement the corresponding features.
``` ```
struct HdfDriverEntry g_i2cDriverEntry = { struct HdfDriverEntry g_i2cDriverEntry = {
...@@ -113,11 +111,11 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha ...@@ -113,11 +111,11 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha
HDF_INIT(g_i2cManagerEntry); HDF_INIT(g_i2cManagerEntry);
``` ```
2. Add the **deviceNode** information to the **device\_info.hcs** file and configure the device attributes in the **i2c\_config.hcs** file. The **deviceNode** information is related to registration of the driver entry. The device attribute values are closely related to the driver implementation and the default values or value ranges of the **I2cCntlr** members at the core layer. 2. Add the **deviceNode** information to the **device\_info.hcs** file and configure the device attributes in the **i2c\_config.hcs** file. The **deviceNode** information is related to registration of the driver entry. The device attribute values are closely related to the driver implementation and the default values or value ranges of the **I2cCntlr** members at the core layer.
In the unified service mode, the first device node in the **device\_info** file must be the I2C manager. [Table 2](#table96651915911) lists settings of its parameters. In the unified service mode, the first device node in the **device\_info** file must be the I2C manager. [Table 2](#table96651915911) lists settings of its parameters.
**Table 2** Settings of the I2C manager **Table 2** Settings of the I2C manager
<a name="table96651915911"></a> <a name="table96651915911"></a>
<table><thead align="left"><tr id="row96618194915"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p1066119790"><a name="p1066119790"></a><a name="p1066119790"></a>Member</p> <table><thead align="left"><tr id="row96618194915"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p1066119790"><a name="p1066119790"></a><a name="p1066119790"></a>Member</p>
...@@ -149,9 +147,9 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha ...@@ -149,9 +147,9 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha
</tbody> </tbody>
</table> </table>
Configure I2C controller information from the second node. This node specifies a type of I2C controllers rather than an I2C controller. The **busID** and **reg\_pbase** parameters distinguish controllers, which can be seen in the **i2c\_config** file. Configure I2C controller information from the second node. This node specifies a type of I2C controllers rather than an I2C controller. The **busID** and **reg\_pbase** parameters distinguish controllers, which can be seen in the **i2c\_config** file.
- **device\_info.hcs** configuration reference - **device\_info.hcs** configuration reference
``` ```
root { root {
...@@ -180,7 +178,7 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha ...@@ -180,7 +178,7 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha
} }
``` ```
- **i2c\_config.hcs** configuration reference - **i2c\_config.hcs** configuration reference
``` ```
root { root {
...@@ -208,10 +206,10 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha ...@@ -208,10 +206,10 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha
} }
``` ```
3. Initialize the **I2cCntlr** object at the core layer, including initializing the vendor custom structure \(transferring parameters and data\), instantiating **I2cMethod** \(used to call underlying functions of the driver\) in **I2cCntlr**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\). 3. Initialize the **I2cCntlr** object at the core layer, including initializing the vendor custom structure \(transferring parameters and data\), instantiating **I2cMethod** \(used to call underlying functions of the driver\) in **I2cCntlr**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\).
- Custom structure reference - Custom structure reference
To the driver, the custom structure carries parameters and data. The values in the **i2c\_config.hcs** file are read by HDF, and the structure members are initialized through **DeviceResourceIface**. Some important values, such as the device number and bus number, are also passed to the **I2cCntlr** object at the core layer. To the driver, the custom structure carries parameters and data. The values in the **i2c\_config.hcs** file are read by HDF, and the structure members are initialized through **DeviceResourceIface**. Some important values, such as the device number and bus number, are also passed to the **I2cCntlr** object at the core layer.
``` ```
// Vendor custom function structure // Vendor custom function structure
...@@ -238,7 +236,7 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha ...@@ -238,7 +236,7 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha
}; };
``` ```
- Instantiate the member callback function structure **I2cMethod** in **I2cCntlr** and the lock callback function structure **I2cLockMethod**. Other members are initialized by using the **Init** function. - Instantiate the member callback function structure **I2cMethod** in **I2cCntlr** and the lock callback function structure **I2cLockMethod**. Other members are initialized by using the **Init** function.
``` ```
// Example in i2c_hi35xx.c // Example in i2c_hi35xx.c
...@@ -256,13 +254,13 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha ...@@ -256,13 +254,13 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values: Return values:
HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **//drivers/framework/include/utils/hdf\_base.h** file.\) HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **//drivers/framework/include/utils/hdf\_base.h** file.\)
**Table 3** Input parameters and return values of the Init function **Table 3** Input parameters and return values of the Init function
<a name="table1743073181511"></a> <a name="table1743073181511"></a>
<table><thead align="left"><tr id="row443033171513"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p34306341517"><a name="p34306341517"></a><a name="p34306341517"></a>Status (Value)</p> <table><thead align="left"><tr id="row443033171513"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p34306341517"><a name="p34306341517"></a><a name="p34306341517"></a>Status (Value)</p>
...@@ -306,7 +304,7 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha ...@@ -306,7 +304,7 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha
Function description: Function description:
Initializes the custom structure object and **I2cCntlr**, calls the **I2cCntlrAdd** function at the core layer, and connects to the VFS \(optional\). Initializes the custom structure object and **I2cCntlr**, calls the **I2cCntlrAdd** function at the core layer, and connects to the VFS \(optional\).
``` ```
static int32_t Hi35xxI2cInit(struct HdfDeviceObject *device) static int32_t Hi35xxI2cInit(struct HdfDeviceObject *device)
...@@ -358,7 +356,7 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha ...@@ -358,7 +356,7 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values: Return values:
...@@ -366,7 +364,7 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha ...@@ -366,7 +364,7 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha
Function description: Function description:
Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF framework fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF framework fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources.
``` ```
static void Hi35xxI2cRelease(struct HdfDeviceObject *device) static void Hi35xxI2cRelease(struct HdfDeviceObject *device)
...@@ -394,7 +392,4 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha ...@@ -394,7 +392,4 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha
} }
return; return;
} }
``` ```
\ No newline at end of file
...@@ -24,7 +24,7 @@ The Improved Inter-Integrated Circuit (I3C) is a simple and cost-efficient bidir ...@@ -24,7 +24,7 @@ The Improved Inter-Integrated Circuit (I3C) is a simple and cost-efficient bidir
}; };
``` ```
**Table 1** APIs for the members in the I3cMethod structure **Table 1** APIs for the members in the I3cMethod structure
|Method|Input Parameter|Output Parameter|Return Value|Description| |Method|Input Parameter|Output Parameter|Return Value|Description|
|-|-|-|-|-| |-|-|-|-|-|
...@@ -52,7 +52,9 @@ The I3C module adaptation involves the following steps: ...@@ -52,7 +52,9 @@ The I3C module adaptation involves the following steps:
3. Instantiate the I3C controller object. 3. Instantiate the I3C controller object.
- Initialize **I3cCntlr**. - Initialize **I3cCntlr**.
- Instantiate **I3cMethod** in **I3cCntlr**. For details, see [Available APIs](#available-apis). - Instantiate **I3cMethod** in **I3cCntlr**.
For details, see [Available APIs](#available-apis).
4. Register an interrupt handler. 4. Register an interrupt handler.
Register an interrupt handler for the controller to implement the device hot-join and in-band interrupt (IBI) features. Register an interrupt handler for the controller to implement the device hot-join and in-band interrupt (IBI) features.
...@@ -197,7 +199,7 @@ The I3C module adaptation involves the following steps: ...@@ -197,7 +199,7 @@ The I3C module adaptation involves the following steps:
- **Init** function - **Init** function
> Input parameter: > Input parameter:
> **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration. > **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration.
> >
> Return value: > Return value:
> **HDF_STATUS** (The following table lists some states. For more details, see **HDF\_STATUS** definition in the **/drivers/framework/include/utils/hdf\_base.h file**.) > **HDF_STATUS** (The following table lists some states. For more details, see **HDF\_STATUS** definition in the **/drivers/framework/include/utils/hdf\_base.h file**.)
...@@ -410,4 +412,4 @@ The I3C module adaptation involves the following steps: ...@@ -410,4 +412,4 @@ The I3C module adaptation involves the following steps:
return HDF_SUCCESS; return HDF_SUCCESS;
} }
``` ```
\ No newline at end of file
# MIPI CSI<a name="EN-US_TOPIC_0000001198067744"></a> # MIPI CSI<a name="EN-US_TOPIC_0000001198067744"></a>
- [Overview](#section72226945170128)
- [Available APIs](#section735525713405)
- [How to Develop](#section378858277170128)
- [Development Example](#section2049027816170128)
## Overview<a name="section72226945170128"></a> ## Overview<a name="section72226945170128"></a>
Defined by the Mobile Industry Processor Interface \(MIPI\) Alliance, the Camera Serial Interface \(CSI\) is a specification that allows data to be transmitted from the camera to the host processor on mobile platforms. In the Hardware Driver Foundation \(HDF\), the MIPI CSI module uses the service-free mode for API adaptation. The service-free mode applies to the devices that do not provide user-mode APIs or the OS that does not distinguish the user mode and the kernel mode. In the service-free mode, DevHandle \(a void pointer\) directly points to the kernel-mode address of the device object. Defined by the Mobile Industry Processor Interface \(MIPI\) Alliance, the Camera Serial Interface \(CSI\) is a specification that allows data to be transmitted from the camera to the host processor on mobile platforms. In the Hardware Driver Foundation \(HDF\), the MIPI CSI module uses the service-free mode for API adaptation. The service-free mode applies to the devices that do not provide user-mode APIs or the OS that does not distinguish the user mode and the kernel mode. In the service-free mode, DevHandle \(a void pointer\) directly points to the kernel-mode address of the device object.
**Figure 1** Service-free mode<a name="fig260692723120"></a> **Figure 1** Service-free mode<a name="fig260692723120"></a>
![](figures/service-free-mode.png "Service-free mode") ![](figures/service-free-mode.png "Service-free mode")
...@@ -34,7 +29,7 @@ struct MipiCsiCntlrMethod { ...@@ -34,7 +29,7 @@ struct MipiCsiCntlrMethod {
}; };
``` ```
**Table 1** Callbacks for the members in the MipiCsiCntlrMethod structure **Table 1** Callbacks for the members in the MipiCsiCntlrMethod structure
<a name="table1233500677170128"></a> <a name="table1233500677170128"></a>
<table><thead align="left"><tr id="row1000451054170128"><th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.1"><p id="entry1111988081170128p0"><a name="entry1111988081170128p0"></a><a name="entry1111988081170128p0"></a>Callback</p> <table><thead align="left"><tr id="row1000451054170128"><th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.1"><p id="entry1111988081170128p0"><a name="entry1111988081170128p0"></a><a name="entry1111988081170128p0"></a>Callback</p>
...@@ -202,35 +197,33 @@ struct MipiCsiCntlrMethod { ...@@ -202,35 +197,33 @@ struct MipiCsiCntlrMethod {
The MIPI CSI module adaptation involves the following steps: The MIPI CSI module adaptation involves the following steps:
1. Instantiate the driver entry. 1. Instantiate the driver entry.
- Instantiate the **HdfDriverEntry** structure. - Instantiate the **HdfDriverEntry** structure.
- Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF. - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF.
2. Configure attribute files. 2. Configure attribute files.
- Add the **deviceNode** information to the **device\_info.hcs** file. - Add the **deviceNode** information to the **device\_info.hcs** file.
- \(Optional\) Add the **mipicsi\_config.hcs** file. - \(Optional\) Add the **mipicsi\_config.hcs** file.
3. Instantiate the MIPI CSI controller object. 3. Instantiate the MIPI CSI controller object.
- Initialize **MipiCsiCntlr**. - Initialize **MipiCsiCntlr**.
- Instantiate **MipiCsiCntlrMethod** in the **MipiCsiCntlr** object. - Instantiate **MipiCsiCntlrMethod** in the **MipiCsiCntlr** object.
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>For details, see [Available APIs](#available-apis).
For details, see [Available APIs](#available-apis).
4. Debug the driver.
- \(Optional\) For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether data is successfully transmitted. 4. \(Optional\) Debug the driver.
For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether data is successfully transmitted.
## Development Example<a name="section2049027816170128"></a> ## Development Example<a name="section2049027816170128"></a>
The following uses **mipi\_rx\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions. The following uses **mipi\_rx\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions.
1. Generally, you need to configure the device attributes in **busxx\_config.hcs** and add the **deviceNode** information to the **device\_info.hcs** file. The device attribute values are closely related to the default values or value range of the **MipiCsiCntlr** members at the core layer. The **deviceNode** information is related to the driver entry registration. 1. Generally, you need to configure the device attributes in **busxx\_config.hcs** and add the **deviceNode** information to the **device\_info.hcs** file. The device attribute values are closely related to the default values or value range of the **MipiCsiCntlr** members at the core layer. The **deviceNode** information is related to the driver entry registration.
>![](../public_sys-resources/icon-note.gif) **NOTE:** >![](../public_sys-resources/icon-note.gif) **NOTE:**
>In this example, the MIPI controller attributes are defined in the source file. If required, add the **deviceMatchAttr** information to **deviceNode** in the **device\_info** file and add the** mipicsi\_config.hcs** file. >In this example, the MIPI controller attributes are defined in the source file. If required, add the **deviceMatchAttr** information to **deviceNode** in the **device\_info** file and add the** mipicsi\_config.hcs** file.
**device\_info.hcs** configuration reference: **device\_info.hcs** configuration reference:
``` ```
root { root {
...@@ -253,9 +246,9 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content ...@@ -253,9 +246,9 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content
} }
``` ```
2. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. The function pointer members of the **HdfDriverEntry** structure are filled by the vendors' operation functions. In the HDF, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke. 2. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. The function pointer members of the **HdfDriverEntry** structure are filled by the vendors' operation functions. In the HDF, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke.
Generally, the HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, the HDF calls **Release** to release driver resources and exit. Generally, the HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, the HDF calls **Release** to release driver resources and exit.
MIPI CSI driver entry reference: MIPI CSI driver entry reference:
...@@ -269,11 +262,11 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content ...@@ -269,11 +262,11 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content
HDF_INIT(g_mipiCsiDriverEntry); // Call HDF_INIT to register the driver entry with the HDF. HDF_INIT(g_mipiCsiDriverEntry); // Call HDF_INIT to register the driver entry with the HDF.
``` ```
3. Initialize the **MipiCsiCntlr** object at the core layer, including initializing the vendor custom structure \(passing parameters and data\), instantiating **MipiCsiCntlrMethod** \(used to call underlying functions of the driver\) in **MipiCsiCntlr**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\). 3. Initialize the **MipiCsiCntlr** object at the core layer, including initializing the vendor custom structure \(passing parameters and data\), instantiating **MipiCsiCntlrMethod** \(used to call underlying functions of the driver\) in **MipiCsiCntlr**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\).
- Custom structure reference: - Custom structure reference:
>![](../public_sys-resources/icon-note.gif) **NOTE:** >![](../public_sys-resources/icon-note.gif) **NOTE:**
>To the driver, the custom structure carries parameters and data. The values in the **config** file are used to initialize the structure members. In this example, the MIPI CSI attributes are defined in the source file. Therefore, the basic member structure is similar to that of **MipiCsiCntlr**. >To the driver, the custom structure carries parameters and data. The values in the **config** file are used to initialize the structure members. In this example, the MIPI CSI attributes are defined in the source file. Therefore, the basic member structure is similar to that of **MipiCsiCntlr**.
``` ```
typedef struct { typedef struct {
...@@ -328,7 +321,7 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content ...@@ -328,7 +321,7 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content
}; };
``` ```
- **\(Important\)** Instantiate the callback function structure **MipiCsiCntlrMethod** in **MipiCsiCntlr**. Other members are initialized by using the **Init** function. - **\(Important\)** Instantiate the callback function structure **MipiCsiCntlrMethod** in **MipiCsiCntlr**. Other members are initialized by using the **Init** function.
``` ```
static struct MipiCsiCntlrMethod g_method = { static struct MipiCsiCntlrMethod g_method = {
...@@ -351,11 +344,11 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content ...@@ -351,11 +344,11 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values: Return values:
HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **/drivers/framework/include/utils/hdf\_base.h** file.\) HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **/drivers/framework/include/utils/hdf\_base.h** file.\)
<a name="table683892652170128"></a> <a name="table683892652170128"></a>
<table><thead align="left"><tr id="row466801181170128"><th class="cellrowborder" valign="top" width="50%" id="mcps1.1.3.1.1"><p id="entry433041536170128p0"><a name="entry433041536170128p0"></a><a name="entry433041536170128p0"></a>Status (Value)</p> <table><thead align="left"><tr id="row466801181170128"><th class="cellrowborder" valign="top" width="50%" id="mcps1.1.3.1.1"><p id="entry433041536170128p0"><a name="entry433041536170128p0"></a><a name="entry433041536170128p0"></a>Status (Value)</p>
...@@ -399,7 +392,7 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content ...@@ -399,7 +392,7 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content
Function description: Function description:
Connects to the **MipiCsiCntlrMethod** instance, calls **MipiCsiRegisterCntlr**, and performs other vendor-defined initialization operations. Connects to the **MipiCsiCntlrMethod** instance, calls **MipiCsiRegisterCntlr**, and performs other vendor-defined initialization operations.
``` ```
static int32_t Hi35xxMipiCsiInit(struct HdfDeviceObject *device) static int32_t Hi35xxMipiCsiInit(struct HdfDeviceObject *device)
...@@ -408,9 +401,9 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content ...@@ -408,9 +401,9 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content
HDF_LOGI("%s: enter!", __func__); HDF_LOGI("%s: enter!", __func__);
g_mipiCsi.priv = NULL; // g_mipiTx is a global variable defined. g_mipiCsi.priv = NULL; // g_mipiTx is a global variable defined.
//static struct MipiCsiCntlr g_mipiCsi = { // static struct MipiCsiCntlr g_mipiCsi = {
//.devNo = 0 // .devNo = 0
//}; // };
g_mipiCsi.ops = &g_method; // Connect to the MipiCsiCntlrMethod instance. g_mipiCsi.ops = &g_method; // Connect to the MipiCsiCntlrMethod instance.
#ifdef CONFIG_HI_PROC_SHOW_SUPPORT #ifdef CONFIG_HI_PROC_SHOW_SUPPORT
g_mipiCsi.debugs = &g_debugMethod; g_mipiCsi.debugs = &g_debugMethod;
...@@ -468,7 +461,7 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content ...@@ -468,7 +461,7 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values: Return values:
...@@ -476,7 +469,7 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content ...@@ -476,7 +469,7 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content
Function description: Function description:
Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the corresponding value assignment operations. Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the corresponding value assignment operations.
``` ```
static void Hi35xxMipiCsiRelease(struct HdfDeviceObject *device) static void Hi35xxMipiCsiRelease(struct HdfDeviceObject *device)
...@@ -484,7 +477,7 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content ...@@ -484,7 +477,7 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content
struct MipiCsiCntlr *cntlr = NULL; struct MipiCsiCntlr *cntlr = NULL;
... ...
cntlr = MipiCsiCntlrFromDevice(device); // A forced conversion from HdfDeviceObject to MipiCsiCntlr is involved. cntlr = MipiCsiCntlrFromDevice(device); // A forced conversion from HdfDeviceObject to MipiCsiCntlr is involved.
//return (device == NULL) ? NULL : (struct MipiCsiCntlr *)device->service; // return (device == NULL) ? NULL : (struct MipiCsiCntlr *)device->service;
... ...
OsalSpinDestroy(&cntlr->ctxLock); OsalSpinDestroy(&cntlr->ctxLock);
...@@ -497,7 +490,4 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content ...@@ -497,7 +490,4 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content
HDF_LOGI("%s: unload mipi csi driver success!", __func__); HDF_LOGI("%s: unload mipi csi driver success!", __func__);
} }
``` ```
\ No newline at end of file
...@@ -2,18 +2,18 @@ ...@@ -2,18 +2,18 @@
## Overview<a name="section16806142183217"></a> ## Overview<a name="section16806142183217"></a>
- The Display Serial Interface \(DSI\) is a specification stipulated by the Mobile Industry Processor Interface \(MIPI\) Alliance, aiming to reduce the cost of display controllers in a mobile device. It defines a serial bus and communication protocol among the host, the source of image data, and the target device. In this way, the DSI can send pixel data or commands to peripherals \(usually LCDs or similar display devices\) in serial mode, or reads information such as status and pixel from the peripherals. The Display Serial Interface \(DSI\) is a specification stipulated by the Mobile Industry Processor Interface \(MIPI\) Alliance, aiming to reduce the cost of display controllers in a mobile device. It defines a serial bus and communication protocol among the host, the source of image data, and the target device. In this way, the DSI can send pixel data or commands to peripherals \(usually LCDs or similar display devices\) in serial mode, or reads information such as status and pixel from the peripherals.
- MIPI DSI is capable of working in both high speed \(HS\) mode and low power \(LP\) mode. All data lanes can only travel from the DSI host to a peripheral in HS mode, except the first data lane, which can also receive data such as status information and pixels from the peripheral in LP mode. The clock lane is dedicated to transmitting synchronization clock signals in HS mode. MIPI DSI is capable of working in both high speed \(HS\) mode and low power \(LP\) mode. All data lanes can only travel from the DSI host to a peripheral in HS mode, except the first data lane, which can also receive data such as status information and pixels from the peripheral in LP mode. The clock lane is dedicated to transmitting synchronization clock signals in HS mode.
- [Figure 1](#fig1122611461203) shows a simplified DSI interface. Conceptually, a DSI-compliant interface has the same features as interfaces complying with DBI-2 and DPI-2 standards. It sends pixels or commands to a peripheral and can read status or pixel information from the peripheral. The main difference is that the DSI serializes all pixel data, commands, and events that, in traditional interfaces, are conveyed to and from the peripheral on a parallel data bus with additional control signals. [Figure 1](#fig1122611461203) shows a simplified DSI interface. Conceptually, a DSI-compliant interface has the same features as interfaces complying with DBI-2 and DPI-2 standards. It sends pixels or commands to a peripheral and can read status or pixel information from the peripheral. The main difference is that the DSI serializes all pixel data, commands, and events that, in traditional interfaces, are conveyed to and from the peripheral on a parallel data bus with additional control signals.
**Figure 1** DSI transmitting and receiving interface<a name="fig1122611461203"></a> **Figure 1** DSI transmitting and receiving interface<a name="fig1122611461203"></a>
![](figures/dsi-transmitting-and-receiving-interface.png "dsi-transmitting-and-receiving-interface") ![](figures/dsi-transmitting-and-receiving-interface.png "dsi-transmitting-and-receiving-interface")
## Available APIs<a name="section12720125432316"></a> ## Available APIs<a name="section12720125432316"></a>
**Table 1** APIs for MIPI DSI **Table 1** APIs for MIPI DSI
<a name="table4199102313245"></a> <a name="table4199102313245"></a>
<table><thead align="left"><tr id="row1619910238244"><th class="cellrowborder" valign="top" width="26.619999999999997%" id="mcps1.2.4.1.1"><p id="p141991023182411"><a name="p141991023182411"></a><a name="p141991023182411"></a>Capability</p> <table><thead align="left"><tr id="row1619910238244"><th class="cellrowborder" valign="top" width="26.619999999999997%" id="mcps1.2.4.1.1"><p id="p141991023182411"><a name="p141991023182411"></a><a name="p141991023182411"></a>Capability</p>
...@@ -75,25 +75,25 @@ ...@@ -75,25 +75,25 @@
</tbody> </tbody>
</table> </table>
>![](../public_sys-resources/icon-note.gif) **NOTE:** >![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>All functions described in this document can be called only in kernel space. >All functions described in this document can be called only in kernel space.
## Usage Guidelines<a name="section037231715335"></a> ## Usage Guidelines<a name="section037231715335"></a>
### How to Use<a name="section49299119344"></a> ### How to Use<a name="section49299119344"></a>
[Figure 2](#fig129103491241) shows the process of using a MIPI DSI device. [Figure 2](#fig129103491241) shows the process of using a MIPI DSI device.
**Figure 2** Process of using a MIPI DSI device<a name="fig129103491241"></a> **Figure 2** Process of using a MIPI DSI device<a name="fig129103491241"></a>
![](figures/process-of-using-a-mipi-dsi-device.png) ![](figures/process-of-using-a-mipi-dsi-device.png)
### Obtaining a MIPI DSI Device Handle<a name="section5126155683811"></a> ### Obtaining a MIPI DSI Device Handle<a name="section5126155683811"></a>
Before performing MIPI DSI communication, obtain a MIPI DSI device handle by calling **MipiDsiOpen**. This function returns a MIPI DSI device handle with a specified channel ID. Before performing MIPI DSI communication, obtain a MIPI DSI device handle by calling **MipiDsiOpen**. This function returns a MIPI DSI device handle with a specified channel ID.
DevHandle MipiDsiOpen\(uint8\_t id\); DevHandle MipiDsiOpen\(uint8\_t id\);
**Table 2** Description of **MipiDsiOpen** **Table 2** Description of **MipiDsiOpen**
<a name="table7603619123820"></a> <a name="table7603619123820"></a>
<table><thead align="left"><tr id="row1060351914386"><th class="cellrowborder" valign="top" width="20.66%" id="mcps1.2.3.1.1"><p id="p14603181917382"><a name="p14603181917382"></a><a name="p14603181917382"></a><strong id="b824620346298"><a name="b824620346298"></a><a name="b824620346298"></a>Parameter</strong></p> <table><thead align="left"><tr id="row1060351914386"><th class="cellrowborder" valign="top" width="20.66%" id="mcps1.2.3.1.1"><p id="p14603181917382"><a name="p14603181917382"></a><a name="p14603181917382"></a><strong id="b824620346298"><a name="b824620346298"></a><a name="b824620346298"></a>Parameter</strong></p>
...@@ -125,7 +125,7 @@ DevHandle MipiDsiOpen\(uint8\_t id\); ...@@ -125,7 +125,7 @@ DevHandle MipiDsiOpen\(uint8\_t id\);
</tbody> </tbody>
</table> </table>
The following example shows how to obtain a MIPI DSI device handle with the channel ID **0**: The following example shows how to obtain a MIPI DSI device handle with the channel ID **0**:
``` ```
DevHandle mipiDsiHandle = NULL; /* Device handle */ DevHandle mipiDsiHandle = NULL; /* Device handle */
...@@ -145,7 +145,7 @@ if (mipiDsiHandle == NULL) { ...@@ -145,7 +145,7 @@ if (mipiDsiHandle == NULL) {
int32\_t MipiDsiSetCfg\(DevHandle handle, struct MipiCfg \*cfg\); int32\_t MipiDsiSetCfg\(DevHandle handle, struct MipiCfg \*cfg\);
**Table 3** Description of **MipiDsiSetCfg** **Table 3** Description of **MipiDsiSetCfg**
<a name="table10692555281"></a> <a name="table10692555281"></a>
<table><thead align="left"><tr id="row116914559288"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p1169195516288"><a name="p1169195516288"></a><a name="p1169195516288"></a><strong id="b1804534152914"><a name="b1804534152914"></a><a name="b1804534152914"></a>Parameter</strong></p> <table><thead align="left"><tr id="row116914559288"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p1169195516288"><a name="p1169195516288"></a><a name="p1169195516288"></a><strong id="b1804534152914"><a name="b1804534152914"></a><a name="b1804534152914"></a>Parameter</strong></p>
...@@ -213,7 +213,7 @@ if (ret != 0) { ...@@ -213,7 +213,7 @@ if (ret != 0) {
int32\_t MipiDsiGetCfg\(DevHandle handle, struct MipiCfg \*cfg\); int32\_t MipiDsiGetCfg\(DevHandle handle, struct MipiCfg \*cfg\);
**Table 4** Description of **MipiDsiGetCfg** **Table 4** Description of **MipiDsiGetCfg**
<a name="table7709554280"></a> <a name="table7709554280"></a>
<table><thead align="left"><tr id="row670115515282"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p470205515287"><a name="p470205515287"></a><a name="p470205515287"></a><strong id="b14806334142912"><a name="b14806334142912"></a><a name="b14806334142912"></a>Parameter</strong></p> <table><thead align="left"><tr id="row670115515282"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p470205515287"><a name="p470205515287"></a><a name="p470205515287"></a><strong id="b14806334142912"><a name="b14806334142912"></a><a name="b14806334142912"></a>Parameter</strong></p>
...@@ -267,7 +267,7 @@ if (ret != HDF_SUCCESS) { ...@@ -267,7 +267,7 @@ if (ret != HDF_SUCCESS) {
int32\_t MipiDsiTx\(PalHandle handle, struct DsiCmdDesc \*cmd\); int32\_t MipiDsiTx\(PalHandle handle, struct DsiCmdDesc \*cmd\);
**Table 5** Description of **MipiDsiTx** **Table 5** Description of **MipiDsiTx**
<a name="table1018490043"></a> <a name="table1018490043"></a>
<table><thead align="left"><tr id="row31848013417"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p1415816132411"><a name="p1415816132411"></a><a name="p1415816132411"></a><strong id="b1280873492913"><a name="b1280873492913"></a><a name="b1280873492913"></a>Parameter</strong></p> <table><thead align="left"><tr id="row31848013417"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p1415816132411"><a name="p1415816132411"></a><a name="p1415816132411"></a><strong id="b1280873492913"><a name="b1280873492913"></a><a name="b1280873492913"></a>Parameter</strong></p>
...@@ -335,7 +335,7 @@ HdfFree(cmd); ...@@ -335,7 +335,7 @@ HdfFree(cmd);
int32\_t MipiDsiRx\(DevHandle handle, struct DsiCmdDesc \*cmd, uint32\_t readLen, uint8\_t \*out\); int32\_t MipiDsiRx\(DevHandle handle, struct DsiCmdDesc \*cmd, uint32\_t readLen, uint8\_t \*out\);
**Table 6** Description of **MipiDsiRx** **Table 6** Description of **MipiDsiRx**
<a name="table223910318361"></a> <a name="table223910318361"></a>
<table><thead align="left"><tr id="row924033173613"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p16240143143611"><a name="p16240143143611"></a><a name="p16240143143611"></a><strong id="b19809334172910"><a name="b19809334172910"></a><a name="b19809334172910"></a>Parameter</strong></p> <table><thead align="left"><tr id="row924033173613"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p16240143143611"><a name="p16240143143611"></a><a name="p16240143143611"></a><strong id="b19809334172910"><a name="b19809334172910"></a><a name="b19809334172910"></a>Parameter</strong></p>
...@@ -417,9 +417,9 @@ After the MIPI DSI communication, release the MIPI DSI device handle by calling ...@@ -417,9 +417,9 @@ After the MIPI DSI communication, release the MIPI DSI device handle by calling
void MipiDsiClose\(DevHandle handle\); void MipiDsiClose\(DevHandle handle\);
This function releases the resources requested by **MipiDsiOpen**. This function releases the resources requested by **MipiDsiOpen**.
**Table 7** Description of **MipiDsiClose** **Table 7** Description of **MipiDsiClose**
<a name="table72517953115"></a> <a name="table72517953115"></a>
<table><thead align="left"><tr id="row1525793312"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p115402031153111"><a name="p115402031153111"></a><a name="p115402031153111"></a><strong id="b1487612133120"><a name="b1487612133120"></a><a name="b1487612133120"></a>Parameter</strong></p> <table><thead align="left"><tr id="row1525793312"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p115402031153111"><a name="p115402031153111"></a><a name="p115402031153111"></a><strong id="b1487612133120"><a name="b1487612133120"></a><a name="b1487612133120"></a>Parameter</strong></p>
...@@ -536,5 +536,4 @@ void PalMipiDsiTestSample(void) ...@@ -536,5 +536,4 @@ void PalMipiDsiTestSample(void)
/* Release the MIPI DSI device handle. */ /* Release the MIPI DSI device handle. */
MipiDsiClose(handle); MipiDsiClose(handle);
} }
``` ```
\ No newline at end of file
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
### Pin<a name="section2"></a> ### Pin<a name="section2"></a>
- The pin, also called pin controller, manages pin resources of system on a chip (SoC) vendors and provides the pin multiplexing function. The pin module, also called pin controller, manages pin resources of system on a chip (SoC) vendors and provides the pin multiplexing function.
- The pin module defines a set of common methods for managing pins, including: The module defines a set of common methods for managing pins, including:
- Obtaining or releasing the pin description handle: The kernel compares the pin name passed in with the pin names of each controller in the linked list. If a match is found, a pin description handle is obtained. After the operation on the pin is complete, the pin description handle will be released. - Obtaining or releasing the pin description handle: The kernel compares the pin name passed in with the pin names of each controller in the linked list. If a match is found, a pin description handle is obtained. After the operation on the pin is complete, the pin description handle will be released.
- Setting or obtaining the pull type of a pin: The pull type can be pull-up, pull-down, or floating. - Setting or obtaining the pull type of a pin: The pull type can be pull-up, pull-down, or floating.
- Setting or obtaining the pull strength of a pin: You can set the pull strength as required. - Setting or obtaining the pull strength of a pin: You can set the pull strength as required.
- Setting or obtaining the functions of a pin to implement pin multiplexing - Setting or obtaining the functions of a pin to implement pin multiplexing
### Basic Concepts<a name="section3"></a> ### Basic Concepts<a name="section3"></a>
Pin, as a software concept, provides APIs for uniformly managing the pins from different SoC vendors, providing the pin multiplexing function, and configuring the electrical features of pins. Pin, as a software concept, provides APIs for uniformly managing the pins from different SoC vendors, providing the pin multiplexing function, and configuring the electrical features of pins.
...@@ -52,7 +52,7 @@ The table below describes the APIs of the pin module. For more details, see API ...@@ -52,7 +52,7 @@ The table below describes the APIs of the pin module. For more details, see API
**Table 1** Pin driver APIs **Table 1** Pin driver APIs
<a name="table1"></a> <a name="table1"></a>
| **API** | **Description** | | **API** | **Description** |
| ------------------------------------------------------------ | ---------------- | | ------------------------------------------------------------ | ---------------- |
| DevHandle PinGet(const char *pinName); | Obtains the pin description handle.| | DevHandle PinGet(const char *pinName); | Obtains the pin description handle.|
| void PinPut(DevHandle handle); | Releases the pin description handle.| | void PinPut(DevHandle handle); | Releases the pin description handle.|
...@@ -88,7 +88,7 @@ DevHandle PinGet(const char *pinName); ...@@ -88,7 +88,7 @@ DevHandle PinGet(const char *pinName);
| Parameter | Description | | Parameter | Description |
| ---------- | ----------------------- | | ---------- | ----------------------- |
| pinName | Pointer to the pin name. | | pinName | Pointer to the pin name. |
| **Return Value**| **Description** | | **Return Value**| **Description** |
| NULL | Failed to obtain the pin description handle.| | NULL | Failed to obtain the pin description handle.|
| handle | Pin description handle obtained. | | handle | Pin description handle obtained. |
...@@ -120,7 +120,7 @@ int32_t PinSetPull(DevHandle handle, enum PinPullType pullType); ...@@ -120,7 +120,7 @@ int32_t PinSetPull(DevHandle handle, enum PinPullType pullType);
| ---------- | ----------------------- | | ---------- | ----------------------- |
| handle | Pin description handle. | | handle | Pin description handle. |
| pullType | Pull type to set. | | pullType | Pull type to set. |
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful.| | 0 | The operation is successful.|
| Negative value | The operation fails.| | Negative value | The operation fails.|
...@@ -154,7 +154,7 @@ int32_t PinGetPull(DevHandle handle, enum PinPullType *pullType); ...@@ -154,7 +154,7 @@ int32_t PinGetPull(DevHandle handle, enum PinPullType *pullType);
| ---------- | ------------------------- | | ---------- | ------------------------- |
| handle | Pin description handle. | | handle | Pin description handle. |
| pullType | Pointer to the pull type obtained.| | pullType | Pointer to the pull type obtained.|
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful. | | 0 | The operation is successful. |
| Negative value | The operation fails. | | Negative value | The operation fails. |
...@@ -187,7 +187,7 @@ int32_t PinSetStrength(DevHandle handle, uint32_t strength); ...@@ -187,7 +187,7 @@ int32_t PinSetStrength(DevHandle handle, uint32_t strength);
| ---------- | ----------------------- | | ---------- | ----------------------- |
| handle | Pin description handle. | | handle | Pin description handle. |
| strength | Pull strength to set. | | strength | Pull strength to set. |
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful.| | 0 | The operation is successful.|
| Negative value | The operation fails.| | Negative value | The operation fails.|
...@@ -221,7 +221,7 @@ int32_t PinGetStrength(DevHandle handle, uint32_t *strength); ...@@ -221,7 +221,7 @@ int32_t PinGetStrength(DevHandle handle, uint32_t *strength);
| ---------- | ------------------------- | | ---------- | ------------------------- |
| handle | Pin description handle. | | handle | Pin description handle. |
| strength | Pointer to the pull strength obtained.| | strength | Pointer to the pull strength obtained.|
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful. | | 0 | The operation is successful. |
| Negative value | The operation fails. | | Negative value | The operation fails. |
...@@ -256,7 +256,7 @@ int32_t PinSetFunc(DevHandle handle, const char *funcName); ...@@ -256,7 +256,7 @@ int32_t PinSetFunc(DevHandle handle, const char *funcName);
| ---------- | ------------------- | | ---------- | ------------------- |
| handle | Pin description handle. | | handle | Pin description handle. |
| funcName | Pointer to the pin function to set. | | funcName | Pointer to the pin function to set. |
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful.| | 0 | The operation is successful.|
| Negative value | The operation fails.| | Negative value | The operation fails.|
...@@ -289,7 +289,7 @@ int32_t PinGetFunc(DevHandle handle, const char **funcName); ...@@ -289,7 +289,7 @@ int32_t PinGetFunc(DevHandle handle, const char **funcName);
| ---------- | --------------------- | | ---------- | --------------------- |
| handle | Pin description handle. | | handle | Pin description handle. |
| funcName | Pointer to the function name obtained.| | funcName | Pointer to the function name obtained.|
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful. | | 0 | The operation is successful. |
| Negative value | The operation fails. | | Negative value | The operation fails. |
...@@ -406,4 +406,4 @@ ERR: ...@@ -406,4 +406,4 @@ ERR:
/* Release the pin description handle. */ /* Release the pin description handle. */
PinPut(handle); PinPut(handle);
return ret; return ret;
} }
\ No newline at end of file
...@@ -266,13 +266,13 @@ The regulator module adaptation procedure is as follows: ...@@ -266,13 +266,13 @@ The regulator module adaptation procedure is as follows:
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration.
Return value: Return value:
**HDF\_STATUS** (The following table lists some states. For more details, see **HDF\_STATUS** in **/drivers/framework/include/utils/hdf\_base.h**.) **HDF\_STATUS** (The following table lists some states. For more details, see **HDF\_STATUS** in **/drivers/framework/include/utils/hdf\_base.h**.)
**Table 2** HDF\_STATUS **Table 2** HDF\_STATUS
| State | Description | | State | Description |
| ---------------------- | -------------- | | ---------------------- | -------------- |
...@@ -319,11 +319,11 @@ The regulator module adaptation procedure is as follows: ...@@ -319,11 +319,11 @@ The regulator module adaptation procedure is as follows:
} }
``` ```
- **Release** function - **Release** function
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration.
Return value: Return value:
...@@ -341,8 +341,6 @@ The regulator module adaptation procedure is as follows: ...@@ -341,8 +341,6 @@ The regulator module adaptation procedure is as follows:
} }
``` ```
4. Debug the driver. 4. (Optional) Debug the driver.
(Optional) Verify the basic functions of the new driver, for example, whether the test cases are successful after the driver is loaded. Verify the basic functions of the new driver, for example, whether the test cases are successful after the driver is loaded.
\ No newline at end of file
...@@ -67,11 +67,11 @@ base/update # Update subsystem repository ...@@ -67,11 +67,11 @@ base/update # Update subsystem repository
**Update subsystem** **Update subsystem**
update\_app [update\_app](https://gitee.com/openharmony/update_app)
update\_updateservice [update\_updateservice](https://gitee.com/openharmony/update_updateservice)
update\_updater [update\_updater](https://gitee.com/openharmony/update_updater)
update\_packaging\_tools [update\_packaging\_tools](https://gitee.com/openharmony/update_packaging_tools)
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册