未验证 提交 29023ac0 编写于 作者: O openharmony_ci 提交者: Gitee

!20980 翻译已完成19576+19565+19555+19578+19597+17907+19545+19669+19694+19749+19747+19742

Merge pull request !20980 from shawn_he/19576-d
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
- [Development of Performance Tracing](hitracemeter-guidelines.md) - [Development of Performance Tracing](hitracemeter-guidelines.md)
- [Development of Distributed Call Chain Tracing](hitracechain-guidelines.md) - [Development of Distributed Call Chain Tracing](hitracechain-guidelines.md)
- [HiLog Development (Native)](hilog-guidelines.md) - [HiLog Development (Native)](hilog-guidelines.md)
- [Development of Performance Tracing (Native)](hitracemeter-native-guidelines.md) - Performance Tracing
- [Development of Performance Tracing (ArkTS)](hitracemeter-guidelines.md)
- [Development of Performance Tracing (Native)](hitracemeter-native-guidelines.md)
- Error Management - Error Management
- [Development of Error Manager](errormanager-guidelines.md) - [Development of Error Manager](errormanager-guidelines.md)
- [Development of Application Recovery](apprecovery-guidelines.md) - [Development of Application Recovery](apprecovery-guidelines.md)
......
# Development of Performance Tracing # Development of Performance Tracing (ArkTS)
## Introduction ## Introduction
...@@ -17,19 +17,19 @@ hiTraceMeter provides APIs for system performance tracing. You can call the APIs ...@@ -17,19 +17,19 @@ hiTraceMeter provides APIs for system performance tracing. You can call the APIs
## Constraints ## Constraints
Due to the asynchronous I/O feature of JS, the hiTraceMeter module provides only asynchronous APIs. - Due to the asynchronous I/O feature of JS, the hiTraceMeter module provides only asynchronous APIs.
## Available APIs ## Available APIs
The performance tracing APIs are provided by the **hiTraceMeter** module. For details, see [API Reference](../reference/apis/js-apis-hitracemeter.md). The performance tracing APIs are provided by the **hiTraceMeter** module. For details, see [API Reference]( ../reference/apis/js-apis-hitracemeter.md).
**APIs for performance tracing** **APIs for performance tracing**
| API | Return Value | Description | | API | Return Value | Description |
| ---------------------------------------------------------------------------- | --------- | ------------ | | ------------------------------------------------------ | ---- | -------------------------------------------------------------------------------------------------------------------- |
| hiTraceMeter.startTrace(name: string, taskId: number) | void | Marks the start of a trace task. If multiple trace tasks with the same name need to be performed at the same time or a trace task needs to be performed multiple times concurrently, different task IDs must be specified in **startTrace**. If the trace tasks with the same name are not performed at the same time, the same task ID can be used.| | hiTraceMeter.startTrace(name: string, taskId: number) | void | Marks the start of a trace task. If multiple trace tasks with the same name need to be performed at the same time or a trace task needs to be performed multiple times concurrently, different task IDs must be specified in **startTrace**. If the trace tasks with the same name are not performed at the same time, the same task ID can be used.|
| hiTraceMeter.finishTrace(name: string, taskId: number) | void | Marks the end of a trace task. The values of **name** and **taskId** must be the same as those of **hiTraceMeter.startTrace**.| | hiTraceMeter.finishTrace(name: string, taskId: number) | void | Marks the end of a trace task. The values of **name** and **taskId** must be the same as those of **hiTraceMeter.startTrace**. |
| hiTraceMeter.traceByValue(name: string, value: number) | void | Marks the value changes of a numeric variable in a trace task.| | hiTraceMeter.traceByValue(name: string, value: number) | void | Marks the value changes of a numeric variable in a trace task. |
## How to Develop ## How to Develop
......
...@@ -468,11 +468,13 @@ Sets the keyboard repeat delay. This API uses an asynchronous callback to return ...@@ -468,11 +468,13 @@ Sets the keyboard repeat delay. This API uses an asynchronous callback to return
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice **System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ | | -------- | ------ | ---- | ------------------------------------------------------------ |
| delay | number | Yes | Keyboard repeat delay, in ms. The value range is [300 ms, 1000 ms] and the default value is **500**.| | delay | number | Yes | Keyboard repeat delay, in ms. The value range is [300, 1000] and the default value is **500**.|
| callback | AsyncCallback<void> | Yes | Callback used to return the result.| | callback | AsyncCallback<void> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -499,6 +501,8 @@ Sets the keyboard repeat delay. This API uses a promise to return the result. ...@@ -499,6 +501,8 @@ Sets the keyboard repeat delay. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice **System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
...@@ -523,6 +527,66 @@ try { ...@@ -523,6 +527,66 @@ try {
} }
``` ```
## inputDevice.getKeyboardRepeatDelay<sup>10+</sup>
getKeyboardRepeatDelay(callback: AsyncCallback&lt;number&gt;): void
Obtains the keyboard repeat delay. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result.|
**Example**
```js
try {
inputDevice.getKeyboardRepeatDelay((error, delay) => {
if (error) {
console.log(`Get keyboard repeat delay failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return;
}
console.log(`Get keyboard repeat delay success`);
});
} catch (error) {
console.log(`Get keyboard repeat delay failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputDevice.getKeyboardRepeatDelay<sup>10+</sup>
getKeyboardRepeatDelay(): Promise&lt;number&gt;
Obtains the keyboard repeat delay. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**System API**: This is a system API.
**Return value**
| Parameters | Description |
| --------------------- | ------------------- |
| Promise&lt;number&gt; | Promise used to return the result.|
**Example**
```js
try {
inputDevice.getKeyboardRepeatDelay().then(delay => {
console.log(`Get keyboard repeat delay success`);
});
} catch (error) {
console.log(`Get keyboard repeat delay failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputDevice.setKeyboardRepeatRate<sup>10+</sup> ## inputDevice.setKeyboardRepeatRate<sup>10+</sup>
setKeyboardRepeatRate(rate: number, callback: AsyncCallback&lt;void&gt;): void setKeyboardRepeatRate(rate: number, callback: AsyncCallback&lt;void&gt;): void
...@@ -531,6 +595,8 @@ Sets the keyboard repeat rate. This API uses an asynchronous callback to return ...@@ -531,6 +595,8 @@ Sets the keyboard repeat rate. This API uses an asynchronous callback to return
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice **System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
...@@ -562,6 +628,8 @@ Sets the keyboard repeat rate. This API uses a promise to return the result. ...@@ -562,6 +628,8 @@ Sets the keyboard repeat rate. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice **System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
...@@ -586,6 +654,66 @@ try { ...@@ -586,6 +654,66 @@ try {
} }
``` ```
## inputDevice.getKeyboardRepeatRate<sup>10+</sup>
getKeyboardRepeatRate(callback: AsyncCallback&lt;number&gt;): void
Obtains the keyboard repeat rate. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | -------------- |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result.|
**Example**
```js
try {
inputDevice.getKeyboardRepeatRate((error, rate) => {
if (error) {
console.log(`Get keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return;
}
console.log(`Get keyboard repeat rate success`);
});
} catch (error) {
console.log(`Get keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputDevice.getKeyboardRepeatRate<sup>10+</sup>
getKeyboardRepeatRate(): Promise&lt;number&gt;
Obtains the keyboard repeat rate. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**System API**: This is a system API.
**Return value**
| Parameters | Description |
| --------------------- | ------------------- |
| Promise&lt;number&gt; | Promise used to return the result.|
**Example**
```js
try {
inputDevice.getKeyboardRepeatRate().then(rate => {
console.log(`Get keyboard repeat rate success`);
});
} catch (error) {
console.log(`Get keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## DeviceListener<sup>9+</sup> ## DeviceListener<sup>9+</sup>
Defines the listener for hot swap events of an input device. Defines the listener for hot swap events of an input device.
......
# @ohos.ai.mindSporeLite (Inference) # @ohos.ai.mindSporeLite (Inference)
The **mindSporeLite** module provides APIs for the MindSpore Lite inference engine to implment model inference.
MindSpore Lite is an AI engine that implements AI model inference for different hardware devices. It has been used in a wide range of fields, such as image classification, target recognition, facial recognition, and character recognition. MindSpore Lite is an AI engine that implements AI model inference for different hardware devices. It has been used in a wide range of fields, such as image classification, target recognition, facial recognition, and character recognition.
The **mindSporeLite** module provides APIs for the MindSpore Lite inference engine to implment model inference.
> **NOTE** > **NOTE**
> >
......
...@@ -849,6 +849,83 @@ observer.off('simStateChange', callback); ...@@ -849,6 +849,83 @@ observer.off('simStateChange', callback);
observer.off('simStateChange'); observer.off('simStateChange');
``` ```
## observer.on('iccAccountInfoChange')<sup>10+</sup>
on\(type: 'iccAccountInfoChange', callback: Callback\<void\>\): void;
Registers an observer for account information change events of the SIM card. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Telephony.StateRegistry
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Account information change event. This field has a fixed value of **iccAccountInfoChange**. |
| callback | Callback\<void\> | Yes | Callback used to return the result.|
**Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
| -------- | -------------------------------------------- |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**Example**
```js
observer.on('iccAccountInfoChange', error => {
console.log("on iccAccountInfoChange, error:" + JSON.stringify(error));
});
```
## observer.off('iccAccountInfoChange')<sup>10+</sup>
off\(type: 'iccAccountInfoChange', callback?: Callback\<void\>\): void;
Unregisters the observer for account information change events of the SIM card. This API uses an asynchronous callback to return the result.
>**NOTE**
>
>You can pass the callback of the **on** function if you want to cancel listening for a certain type of event. If you do not pass the callback, you will cancel listening for all events.
**System capability**: SystemCapability.Telephony.StateRegistry
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Account information change event. This field has a fixed value of **iccAccountInfoChange**. |
| callback | Callback\<void\> | No | Callback used to return the result.|
**Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
| -------- | -------------------------------------------- |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**Example**
```js
let callback = data => {
console.log("on iccAccountInfoChange, data:" + JSON.stringify(data));
}
observer.on('iccAccountInfoChange', callback);
// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks.
observer.off('iccAccountInfoChange', callback);
observer.off('iccAccountInfoChange');
```
## LockReason<sup>8+</sup> ## LockReason<sup>8+</sup>
......
...@@ -147,7 +147,7 @@ try { ...@@ -147,7 +147,7 @@ try {
## power.suspend<sup>9+</sup> ## power.suspend<sup>9+</sup>
suspend(): void suspend(isImmediate?: boolean): void
Hibernates a device. Hibernates a device.
...@@ -155,6 +155,13 @@ Hibernates a device. ...@@ -155,6 +155,13 @@ Hibernates a device.
**System capability:** SystemCapability.PowerManager.PowerManager.Core **System capability:** SystemCapability.PowerManager.PowerManager.Core
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------- |
| isImmediate<sup>10+</sup> | boolean | No | Whether to hibernate a device immediately. If this parameter is not specified, the default value **false** is used. The system automatically determines when to enter the hibernation state.<br>**NOTE**: This parameter is supported since API version 10.|
**Error codes** **Error codes**
For details about the error codes, see [Power Manager Error Codes](../errorcodes/errorcode-power.md). For details about the error codes, see [Power Manager Error Codes](../errorcodes/errorcode-power.md).
...@@ -289,6 +296,39 @@ power.setPowerMode(power.DevicePowerMode.MODE_PERFORMANCE) ...@@ -289,6 +296,39 @@ power.setPowerMode(power.DevicePowerMode.MODE_PERFORMANCE)
}); });
``` ```
## power.isStandby<sup>10+</sup>
isStandby(): boolean
Checks whether the device is in standby mode.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
**Return value**
| Type | Description |
| ------------------- | -------------------------------------- |
| boolean | The value **true** indicates that the device is in standby mode, and the value **false** indicates the opposite.|
**Error codes**
For details about the error codes, see [Power Manager Error Codes](../errorcodes/errorcode-power.md).
| ID | Error Message |
|---------|---------|
| 4900101 | If connecting to the service failed. |
**Example**
```js
try {
var isStandby = power.isStandby();
console.info('device is in standby: ' + isStandby);
} catch(err) {
console.error('check isStandby failed, err: ' + err);
}
```
## power.rebootDevice<sup>(deprecated)</sup> ## power.rebootDevice<sup>(deprecated)</sup>
rebootDevice(reason: string): void rebootDevice(reason: string): void
......
...@@ -15,7 +15,7 @@ import shortKey from '@ohos.multimodalInput.shortKey'; ...@@ -15,7 +15,7 @@ import shortKey from '@ohos.multimodalInput.shortKey';
## shortKey.setKeyDownDuration ## shortKey.setKeyDownDuration
setKeyDownDuration(businessId: string, delay: number, callback: AsyncCallback&lt;void&gt;): void setKeyDownDuration(businessKey: string, delay: number, callback: AsyncCallback&lt;void&gt;): void
Sets the delay for starting an ability using the shortcut key. This API uses an asynchronous callback to return the result. Sets the delay for starting an ability using the shortcut key. This API uses an asynchronous callback to return the result.
...@@ -25,7 +25,7 @@ Sets the delay for starting an ability using the shortcut key. This API uses an ...@@ -25,7 +25,7 @@ Sets the delay for starting an ability using the shortcut key. This API uses an
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------------------- | ---- | ------------------------------------------------------------ | | ---------- | ------------------- | ---- | ------------------------------------------------------------ |
| businessId | string | Yes | Unique service ID registered on the multimodal side. It corresponds to **businessId** in the **ability_launch_config.json** file.| | businessKey| string | Yes | Unique service ID registered on the multimodal side. It corresponds to **businessId** in the **ability_launch_config.json** file.|
| delay | number | Yes | Delay for starting an ability using the shortcut key, in ms.| | delay | number | Yes | Delay for starting an ability using the shortcut key, in ms.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
...@@ -49,7 +49,7 @@ try { ...@@ -49,7 +49,7 @@ try {
## shortKey.setKeyDownDuration ## shortKey.setKeyDownDuration
setKeyDownDuration(businessId: string, delay: number): Promise&lt;void&gt; setKeyDownDuration(businessKey: string, delay: number): Promise&lt;void&gt;
Sets the delay for starting an ability using the shortcut key. This API uses a promise to return the result. Sets the delay for starting an ability using the shortcut key. This API uses a promise to return the result.
...@@ -59,7 +59,7 @@ Sets the delay for starting an ability using the shortcut key. This API uses a p ...@@ -59,7 +59,7 @@ Sets the delay for starting an ability using the shortcut key. This API uses a p
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------ | ---- | ------------------------------------------------------------ | | ---------- | ------ | ---- | ------------------------------------------------------------ |
| businessId | string | Yes | Unique service ID registered on the multimodal side. It corresponds to **businessId** in the **ability_launch_config.json** file.| | businessKey| string | Yes | Unique service ID registered on the multimodal side. It corresponds to **businessId** in the **ability_launch_config.json** file.|
| delay | number | Yes | Delay for starting an ability using the shortcut key, in ms.| | delay | number | Yes | Delay for starting an ability using the shortcut key, in ms.|
**Return value** **Return value**
......
...@@ -615,7 +615,7 @@ Checks whether the SIM card in the specified slot is installed. This API uses an ...@@ -615,7 +615,7 @@ Checks whether the SIM card in the specified slot is installed. This API uses an
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | -------------------------------------- | | -------- | --------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. The value **true** indicates that the SIM card in the specified slot is installed, and the value **false** indicates the opposite. |
**Error codes** **Error codes**
...@@ -681,13 +681,15 @@ promise.then(data => { ...@@ -681,13 +681,15 @@ promise.then(data => {
}); });
``` ```
## sim.getSimAccountInfo<sup>7+</sup> ## sim.getSimAccountInfo<sup>10+</sup>
getSimAccountInfo\(slotId: number, callback: AsyncCallback\<IccAccountInfo\>\): void getSimAccountInfo\(slotId: number, callback: AsyncCallback\<IccAccountInfo\>\): void
Obtains SIM card account information. This API uses an asynchronous callback to return the result. Obtains SIM card account information. This API uses an asynchronous callback to return the result.
**System API**: This is a system API. >**NOTE**
>
>If you do not have the **GET_TELEPHONY_STATE** permission, the ICCID and number information is empty.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE **Required permission**: ohos.permission.GET_TELEPHONY_STATE
...@@ -706,8 +708,6 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -706,8 +708,6 @@ For details about the following error codes, see [Telephony Error Codes](../../r
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 202 | Non-system applications use system APIs. |
| 401 | Parameter error. | | 401 | Parameter error. |
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
...@@ -725,13 +725,15 @@ sim.getSimAccountInfo(0, (err, data) => { ...@@ -725,13 +725,15 @@ sim.getSimAccountInfo(0, (err, data) => {
``` ```
## sim.getSimAccountInfo<sup>7+</sup> ## sim.getSimAccountInfo<sup>10+</sup>
getSimAccountInfo\(slotId: number\): Promise\<IccAccountInfo\> getSimAccountInfo\(slotId: number\): Promise\<IccAccountInfo\>
Obtains SIM card account information. This API uses a promise to return the result. Obtains SIM card account information. This API uses a promise to return the result.
**System API**: This is a system API. >**NOTE**
>
>If you do not have the **GET_TELEPHONY_STATE** permission, the ICCID and number information is empty.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE **Required permission**: ohos.permission.GET_TELEPHONY_STATE
...@@ -755,8 +757,6 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -755,8 +757,6 @@ For details about the following error codes, see [Telephony Error Codes](../../r
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 202 | Non-system applications use system APIs. |
| 401 | Parameter error. | | 401 | Parameter error. |
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
...@@ -776,13 +776,15 @@ promise.then(data => { ...@@ -776,13 +776,15 @@ promise.then(data => {
}); });
``` ```
## sim.getActiveSimAccountInfoList<sup>8+</sup> ## sim.getActiveSimAccountInfoList<sup>10+</sup>
getActiveSimAccountInfoList\(callback: AsyncCallback\<Array\<IccAccountInfo\>\>\): void getActiveSimAccountInfoList\(callback: AsyncCallback\<Array\<IccAccountInfo\>\>\): void
Obtains the account information list of the active SIM card. This API uses an asynchronous callback to return the result. Obtains the account information list of the active SIM card. This API uses an asynchronous callback to return the result.
**System API**: This is a system API. >**NOTE**
>
>If you do not have the **GET_TELEPHONY_STATE** permission, the ICCID and number information is empty.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE **Required permission**: ohos.permission.GET_TELEPHONY_STATE
...@@ -800,8 +802,6 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -800,8 +802,6 @@ For details about the following error codes, see [Telephony Error Codes](../../r
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 202 | Non-system applications use system APIs. |
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. | | 8300003 | System internal error. |
...@@ -817,13 +817,15 @@ sim.getActiveSimAccountInfoList((err, data) => { ...@@ -817,13 +817,15 @@ sim.getActiveSimAccountInfoList((err, data) => {
``` ```
## sim.getActiveSimAccountInfoList<sup>8+</sup> ## sim.getActiveSimAccountInfoList<sup>10+</sup>
getActiveSimAccountInfoList\(\): Promise\<Array\<IccAccountInfo\>\>; getActiveSimAccountInfoList\(\): Promise\<Array\<IccAccountInfo\>\>;
Obtains the account information list of the active SIM card. This API uses a promise to return the result. Obtains the account information list of the active SIM card. This API uses a promise to return the result.
**System API**: This is a system API. >**NOTE**
>
>If you do not have the **GET_TELEPHONY_STATE** permission, the ICCID and number information is empty.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE **Required permission**: ohos.permission.GET_TELEPHONY_STATE
...@@ -841,8 +843,6 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -841,8 +843,6 @@ For details about the following error codes, see [Telephony Error Codes](../../r
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 202 | Non-system applications use system APIs. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. | | 8300003 | System internal error. |
| 8300004 | Do not have sim card. | | 8300004 | Do not have sim card. |
...@@ -2250,6 +2250,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -2250,6 +2250,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
| 202 | Non-system applications use system APIs. |
| 401 | Parameter error. | | 401 | Parameter error. |
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
...@@ -2302,6 +2303,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -2302,6 +2303,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
| 202 | Non-system applications use system APIs. |
| 401 | Parameter error. | | 401 | Parameter error. |
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
...@@ -3990,6 +3992,80 @@ try { ...@@ -3990,6 +3992,80 @@ try {
} }
``` ```
## sim.getDefaultVoiceSimId<sup>10+</sup>
getDefaultVoiceSimId\(callback: AsyncCallback\<number\>\): void
Obtains the default slot ID of the SIM card that provides voice services. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result.<br>The return value is bound to the SIM card and increases from 1.|
**Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
| -------- | -------------------------------------------- |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300004 | Do not have sim card. |
| 8300999 | Unknown error code. |
| 8301001 | SIM card is not activated. |
**Example**
```js
sim.getDefaultVoiceSimId((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sim.getDefaultVoiceSimId<sup>10+</sup>
getDefaultVoiceSimId\(\): Promise\<number\>
Obtains the default slot ID of the SIM card that provides voice services. This API uses a promise to return the result.
**System capability**: SystemCapability.Telephony.CoreService
**Return value**
| Type | Description |
| ----------------- | --------------------------------------- |
| Promise\<number\> | Promise used to return the result.<br>The return value is bound to the SIM card and increases from 1.|
**Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
| -------- | -------------------------------------------- |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300004 | Do not have sim card. |
| 8300999 | Unknown error code. |
| 8301001 | SIM card is not activated. |
**Example**
```js
let promise = sim.getDefaultVoiceSimId();
promise.then(data => {
console.log(`getDefaultVoiceSimId success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`getDefaultVoiceSimId failed, promise: err->${JSON.stringify(err)}`);
});
```
## SimState ## SimState
Enumerates SIM card states. Enumerates SIM card states.
...@@ -4113,7 +4189,7 @@ Defines the personalized lock information. ...@@ -4113,7 +4189,7 @@ Defines the personalized lock information.
## IccAccountInfo<sup>7+</sup> ## IccAccountInfo<sup>7+</sup>
Defines the ICC account information. ICC account information.
**System API**: This is a system API. **System API**: This is a system API.
......
...@@ -99,12 +99,16 @@ promise.then(data => { ...@@ -99,12 +99,16 @@ promise.then(data => {
}); });
``` ```
## sms.sendMessage ## sms.sendMessage<sup>(deprecated)</sup>
sendMessage\(options: SendMessageOptions\): void sendMessage\(options: SendMessageOptions\): void
Sends an SMS message. Sends an SMS message.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 10. You are advised to use [sendShortMessage](#smssendshortmessage10).
**Required permissions**: ohos.permission.SEND_MESSAGES **Required permissions**: ohos.permission.SEND_MESSAGES
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
...@@ -146,6 +150,114 @@ let options = {slotId, content, destinationHost, serviceCenter, destinationPort, ...@@ -146,6 +150,114 @@ let options = {slotId, content, destinationHost, serviceCenter, destinationPort,
sms.sendMessage(options); sms.sendMessage(options);
``` ```
## sms.sendShortMessage<sup>10+</sup>
sendShortMessage\(options: SendMessageOptions, callback: AsyncCallback&lt;void&gt;\): void
Sends an SMS message. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.SEND_MESSAGES
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------------------------------------- |
| options | [SendMessageOptions](#sendmessageoptions) | Yes | Options (including the callback) for sending an SMS message.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**Example**
```js
let sendCallback = function (err, data) {
console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}
let deliveryCallback = function (err, data) {
console.log(`deliveryCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}
let slotId = 0;
let content ='SMS message content';
let destinationHost = '+861xxxxxxxxxx';
let serviceCenter = '+861xxxxxxxxxx';
let destinationPort = 1000;
let options = {slotId, content, destinationHost, serviceCenter, destinationPort, sendCallback, deliveryCallback};
sms.sendMessage(options, (err) => {
console.log(`callback: err->${JSON.stringify(err)}`);
});
```
## sms.sendShortMessage<sup>10+</sup>
sendShortMessage\(options: SendMessageOptions\): Promise&lt;void&gt;
Sends an SMS message. This API uses a promise to return the result.
**Required permissions**: ohos.permission.SEND_MESSAGES
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------------------------------------- |
| options | [SendMessageOptions](#sendmessageoptions) | Yes | Options (including the callback) for sending an SMS message.|
**Return value**
| Type | Description |
| --------------- | ------------------------------------------------------------ |
| Promise&lt;void&gt; | Promise used to return the result.|
**Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**Example**
```js
let sendCallback = function (err, data) {
console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}
let deliveryCallback = function (err, data) {
console.log(`deliveryCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}
let slotId = 0;
let content ='SMS message content';
let destinationHost = '+861xxxxxxxxxx';
let serviceCenter = '+861xxxxxxxxxx';
let destinationPort = 1000;
let options = {slotId, content, destinationHost, serviceCenter, destinationPort, sendCallback, deliveryCallback};
let promise = sms.sendShortMessage(options);
promise.then(() => {
console.log(`sendShortMessage success`);
}).catch(err => {
console.error(`sendShortMessage failed, promise: err->${JSON.stringify(err)}`);
});
```
## sms.getDefaultSmsSlotId<sup>7+</sup> ## sms.getDefaultSmsSlotId<sup>7+</sup>
...@@ -1371,6 +1483,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -1371,6 +1483,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 202 | Non-system applications use system APIs. |
| 401 | Parameter error. | | 401 | Parameter error. |
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
...@@ -1415,6 +1528,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -1415,6 +1528,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 202 | Non-system applications use system APIs. |
| 401 | Parameter error. | | 401 | Parameter error. |
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
...@@ -1456,6 +1570,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -1456,6 +1570,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 202 | Non-system applications use system APIs. |
| 401 | Parameter error. | | 401 | Parameter error. |
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
...@@ -1508,6 +1623,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -1508,6 +1623,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 202 | Non-system applications use system APIs. |
| 401 | Parameter error. | | 401 | Parameter error. |
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
...@@ -1534,6 +1650,81 @@ promise.then(data => { ...@@ -1534,6 +1650,81 @@ promise.then(data => {
}); });
``` ```
## sms.getDefaultSmsSimId<sup>10+</sup>
getDefaultSmsSimId\(callback: AsyncCallback&lt;number&gt;\): void
Obtains the default ID of the SIM card used to send SMS messages. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------------------------------------- |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result.<br>The return value is bound to the SIM card and increases from 1.|
**Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
| -------- | -------------------------------------------- |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300004 | Do not have sim card. |
| 8300999 | Unknown error code. |
| 8301001 | SIM card is not activated. |
**Example**
```js
sms.getDefaultSmsSimId((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sms.getDefaultSmsSimId<sup>10+</sup>
getDefaultSmsSimId\(\): Promise&lt;number&gt;
Obtains the default ID of the SIM card used to send SMS messages. This API uses a promise to return the result.
**System capability**: SystemCapability.Telephony.SmsMms
**Return value**
| Type | Description |
| --------------- | ------------------------------------------------------------ |
| Promise&lt;number&gt; | Promise used to return the result.<br>The return value is bound to the SIM card and increases from 1.|
**Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
| -------- | -------------------------------------------- |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300004 | Do not have sim card. |
| 8300999 | Unknown error code. |
| 8301001 | SIM card is not activated. |
**Example**
```js
let promise = sms.getDefaultSmsSimId();
promise.then(data => {
console.log(`getDefaultSmsSimId success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`getDefaultSmsSimId failed, promise: err->${JSON.stringify(err)}`);
});
```
## ShortMessage ## ShortMessage
Defines an SMS message instance. Defines an SMS message instance.
...@@ -2026,7 +2217,7 @@ Defines an MMS message delivery index. ...@@ -2026,7 +2217,7 @@ Defines an MMS message delivery index.
| messageId | string | Yes | Message ID.| | messageId | string | Yes | Message ID.|
| date | number | Yes | Date. | | date | number | Yes | Date. |
| to | Array<[MmsAddress](#mmsaddress8)\> | Yes | Destination address.| | to | Array<[MmsAddress](#mmsaddress8)\> | Yes | Destination address.|
| status | number | Yes | Status | | status | number | Yes | Status. |
| version | [MmsVersionType](#mmsversiontype8) | Yes | Version. | | version | [MmsVersionType](#mmsversiontype8) | Yes | Version. |
## MmsRespInd<sup>8+</sup> ## MmsRespInd<sup>8+</sup>
...@@ -2040,7 +2231,7 @@ Defines an MMS response index. ...@@ -2040,7 +2231,7 @@ Defines an MMS response index.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------- | ---------------------------------- | ---- | -------- | | ------------- | ---------------------------------- | ---- | -------- |
| transactionId | string | Yes | Event ID. | | transactionId | string | Yes | Event ID. |
| status | number | Yes | Status | | status | number | Yes | Status. |
| version | [MmsVersionType](#mmsversiontype8) | Yes | Version. | | version | [MmsVersionType](#mmsversiontype8) | Yes | Version. |
| reportAllowed | [ReportType](#reporttype8) | No | Report allowed.| | reportAllowed | [ReportType](#reporttype8) | No | Report allowed.|
......
...@@ -2398,7 +2398,7 @@ Enables listening for **close** events of a **TCPSocketConnection** object. This ...@@ -2398,7 +2398,7 @@ Enables listening for **close** events of a **TCPSocketConnection** object. This
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------- | ---- | ----------------------------------- | | -------- | ---------------- | ---- | ----------------------------------- |
| type | string | Yes | Type of the event to subscribe to.<br/> **close**: close event| | type | string | Yes | Type of the event to subscribe to.<br/> **close**: close event|
| callback | Callback\<void\> | No | Callback used to return the result. | | callback | Callback\<void\> | Yes | Callback used to return the result. |
**Error codes** **Error codes**
......
# @ohos.telephony.data (Cellular Data) # @ohos.telephony.data (Cellular Data)
The cellular data module provides basic mobile data management functions. You can obtain and set the default slot of the SIM card used for mobile data, and obtain the uplink and downlink connection status of cellular data services and connection status of the packet switched (PS) domain. Besides, you can check whether cellular data services and data roaming are enabled. The **data** module provides basic mobile data management functions. You can obtain and set the default slot of the SIM card used for mobile data, and obtain the uplink and downlink connection status of cellular data services and connection status of the packet switched (PS) domain. Besides, you can check whether cellular data services and data roaming are enabled.
>**NOTE** >**NOTE**
> >
...@@ -24,7 +24,7 @@ Obtains the default slot of the SIM card used for mobile data. This API uses an ...@@ -24,7 +24,7 @@ Obtains the default slot of the SIM card used for mobile data. This API uses an
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ------------------------------------------ | | -------- | ----------------------- | ---- | ------------------------------------------ |
| callback | AsyncCallback\<number\> | Yes | Callback used to return the result.<br>**0**: card slot 1<br>**1**: card slot 2| | callback | AsyncCallback\<number\> | Yes | Callback used to return the result.<br>**0**: card slot 1.<br>**1**: card slot 2.|
**Example** **Example**
...@@ -46,7 +46,7 @@ Obtains the default slot of the SIM card used for mobile data. This API uses a p ...@@ -46,7 +46,7 @@ Obtains the default slot of the SIM card used for mobile data. This API uses a p
| Type | Description | | Type | Description |
| ----------------- | ------------------------------------------------------------ | | ----------------- | ------------------------------------------------------------ |
| Promise\<number\> | Promise used to return the result.<br>**0**: card slot 1<br>**1**: card slot 2| | Promise\<number\> | Promise used to return the result.<br>**0**: card slot 1.<br>**1**: card slot 2.|
**Example** **Example**
...@@ -71,7 +71,7 @@ Obtains the default SIM card used for mobile data synchronously. ...@@ -71,7 +71,7 @@ Obtains the default SIM card used for mobile data synchronously.
| Type | Description | | Type | Description |
| ------ | -------------------------------------------------- | | ------ | -------------------------------------------------- |
| number | Card slot ID.<br>**0**: card slot 1<br>**1**: card slot 2| | number | Card slot ID.<br>**0**: card slot 1.<br>**1**: card slot 2.|
**Example** **Example**
...@@ -87,7 +87,7 @@ Sets the default slot of the SIM card used for mobile data. This API uses an asy ...@@ -87,7 +87,7 @@ Sets the default slot of the SIM card used for mobile data. This API uses an asy
**System API**: This is a system API. **System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE **Required permissions**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CellularData **System capability**: SystemCapability.Telephony.CellularData
...@@ -95,7 +95,7 @@ Sets the default slot of the SIM card used for mobile data. This API uses an asy ...@@ -95,7 +95,7 @@ Sets the default slot of the SIM card used for mobile data. This API uses an asy
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------- | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | SIM card slot ID. <br>**0**: card slot 1<br>**1**: card slot 2<br>**-1**: Clears the default configuration.| | slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1.<br>- **1**: card slot 2.<br>- **-1**: Clears the default configuration.|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. | | callback | AsyncCallback\<void\> | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -130,7 +130,7 @@ Sets the default slot of the SIM card used for mobile data. This API uses a prom ...@@ -130,7 +130,7 @@ Sets the default slot of the SIM card used for mobile data. This API uses a prom
**System API**: This is a system API. **System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE **Required permissions**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CellularData **System capability**: SystemCapability.Telephony.CellularData
...@@ -138,7 +138,7 @@ Sets the default slot of the SIM card used for mobile data. This API uses a prom ...@@ -138,7 +138,7 @@ Sets the default slot of the SIM card used for mobile data. This API uses a prom
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ | | ------ | ------ | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | SIM card slot ID. <br>**0**: card slot 1<br>**1**: card slot 2<br>**-1**: Clears the default configuration.| | slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1.<br>- **1**: card slot 2.<br>- **-1**: Clears the default configuration.|
**Return value** **Return value**
...@@ -356,7 +356,7 @@ Checks whether roaming is enabled for the cellular data service. This API uses a ...@@ -356,7 +356,7 @@ Checks whether roaming is enabled for the cellular data service. This API uses a
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------ | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | Card slot ID.<br>**0**: card slot 1<br>**1**: card slot 2 | | slotId | number | Yes | Card slot ID.<br>**0**: card slot 1.<br>**1**: card slot 2. |
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.<br>**true**: Roaming is enabled for the cellular data service.<br>**false**: Roaming is disabled for the cellular data service.| | callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.<br>**true**: Roaming is enabled for the cellular data service.<br>**false**: Roaming is disabled for the cellular data service.|
**Error codes** **Error codes**
...@@ -394,7 +394,7 @@ Checks whether roaming is enabled for the cellular data service. This API uses a ...@@ -394,7 +394,7 @@ Checks whether roaming is enabled for the cellular data service. This API uses a
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------------------------------- | | ------ | ------ | ---- | ---------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>**0**: card slot 1<br>**1**: card slot 2| | slotId | number | Yes | Card slot ID.<br>**0**: card slot 1.<br>**1**: card slot 2.|
**Return value** **Return value**
...@@ -434,7 +434,7 @@ Enables the cellular data service. This API uses an asynchronous callback to ret ...@@ -434,7 +434,7 @@ Enables the cellular data service. This API uses an asynchronous callback to ret
**System API**: This is a system API. **System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE **Required permissions**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CellularData **System capability**: SystemCapability.Telephony.CellularData
...@@ -474,7 +474,7 @@ Enables the cellular data service. This API uses a promise to return the result. ...@@ -474,7 +474,7 @@ Enables the cellular data service. This API uses a promise to return the result.
**System API**: This is a system API. **System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE **Required permissions**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CellularData **System capability**: SystemCapability.Telephony.CellularData
...@@ -515,7 +515,7 @@ Disables the cellular data service. This API uses an asynchronous callback to re ...@@ -515,7 +515,7 @@ Disables the cellular data service. This API uses an asynchronous callback to re
**System API**: This is a system API. **System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE **Required permissions**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CellularData **System capability**: SystemCapability.Telephony.CellularData
...@@ -555,7 +555,7 @@ Disables the cellular data service. This API uses a promise to return the result ...@@ -555,7 +555,7 @@ Disables the cellular data service. This API uses a promise to return the result
**System API**: This is a system API. **System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE **Required permissions**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CellularData **System capability**: SystemCapability.Telephony.CellularData
...@@ -596,7 +596,7 @@ Enables the cellular data roaming service. This API uses an asynchronous callbac ...@@ -596,7 +596,7 @@ Enables the cellular data roaming service. This API uses an asynchronous callbac
**System API**: This is a system API. **System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE **Required permissions**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CellularData **System capability**: SystemCapability.Telephony.CellularData
...@@ -604,7 +604,7 @@ Enables the cellular data roaming service. This API uses an asynchronous callbac ...@@ -604,7 +604,7 @@ Enables the cellular data roaming service. This API uses an asynchronous callbac
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ---------------------------------------- | | -------- | --------------------- | ---- | ---------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>**0**: card slot 1<br>**1**: card slot 2| | slotId | number | Yes | Card slot ID.<br>**0**: card slot 1.<br>**1**: card slot 2.|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. | | callback | AsyncCallback\<void\> | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -637,7 +637,7 @@ Enables the cellular data roaming service. This API uses a promise to return the ...@@ -637,7 +637,7 @@ Enables the cellular data roaming service. This API uses a promise to return the
**System API**: This is a system API. **System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE **Required permissions**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CellularData **System capability**: SystemCapability.Telephony.CellularData
...@@ -645,7 +645,7 @@ Enables the cellular data roaming service. This API uses a promise to return the ...@@ -645,7 +645,7 @@ Enables the cellular data roaming service. This API uses a promise to return the
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------------------------------- | | ------ | ------ | ---- | ---------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>**0**: card slot 1<br>**1**: card slot 2| | slotId | number | Yes | Card slot ID.<br>**0**: card slot 1.<br>**1**: card slot 2.|
**Return value** **Return value**
...@@ -686,7 +686,7 @@ Disables the cellular data roaming service. This API uses an asynchronous callba ...@@ -686,7 +686,7 @@ Disables the cellular data roaming service. This API uses an asynchronous callba
**System API**: This is a system API. **System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE **Required permissions**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CellularData **System capability**: SystemCapability.Telephony.CellularData
...@@ -694,7 +694,7 @@ Disables the cellular data roaming service. This API uses an asynchronous callba ...@@ -694,7 +694,7 @@ Disables the cellular data roaming service. This API uses an asynchronous callba
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ---------------------------------------- | | -------- | --------------------- | ---- | ---------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>**0**: card slot 1<br>**1**: card slot 2| | slotId | number | Yes | Card slot ID.<br>**0**: card slot 1.<br>**1**: card slot 2.|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. | | callback | AsyncCallback\<void\> | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -727,7 +727,7 @@ Disables the cellular data roaming service. This API uses a promise to return th ...@@ -727,7 +727,7 @@ Disables the cellular data roaming service. This API uses a promise to return th
**System API**: This is a system API. **System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE **Required permissions**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CellularData **System capability**: SystemCapability.Telephony.CellularData
...@@ -735,7 +735,7 @@ Disables the cellular data roaming service. This API uses a promise to return th ...@@ -735,7 +735,7 @@ Disables the cellular data roaming service. This API uses a promise to return th
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------------------------------- | | ------ | ------ | ---- | ---------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>**0**: card slot 1<br>**1**: card slot 2| | slotId | number | Yes | Card slot ID.<br>**0**: card slot 1.<br>**1**: card slot 2.|
**Return value** **Return value**
...@@ -768,6 +768,26 @@ promise.then(() => { ...@@ -768,6 +768,26 @@ promise.then(() => {
}); });
``` ```
## data.getDefaultCellularDataSimId<sup>10+</sup>
getDefaultCellularDataSimId(): number
Obtains the default ID of the SIM card used for mobile data.
**System capability**: SystemCapability.Telephony.CellularData
**Return value**
| Type | Description |
| ------ | -------------------------------------------------- |
| number | Obtains the default ID of the SIM card used for mobile data.<br>The return value is bound to the SIM card and increases from 1.|
**Example**
```js
console.log("Result: "+ data.getDefaultCellularDataSimId())
```
## DataFlowType ## DataFlowType
Defines the cellular data flow type. Defines the cellular data flow type.
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
- [HuksTypeApi](_huks_type_api.md) - [HuksTypeApi](_huks_type_api.md)
- [Init](init.md) - [Init](init.md)
- [Memory](memory.md) - [Memory](memory.md)
- [UsbDdk](_usb_ddk.md)
- [Hitrace](_hitrace.md)
- Header Files - Header Files
- [drawing_bitmap.h](drawing__bitmap_8h.md) - [drawing_bitmap.h](drawing__bitmap_8h.md)
- [drawing_brush.h](drawing__brush_8h.md) - [drawing_brush.h](drawing__brush_8h.md)
...@@ -87,6 +89,9 @@ ...@@ -87,6 +89,9 @@
- [relational_store.h](relational__store_8h.md) - [relational_store.h](relational__store_8h.md)
- [syscap_ndk.h](syscap__ndk_8h.md) - [syscap_ndk.h](syscap__ndk_8h.md)
- [purgeable_memory.h](purgeable__memory_8h.md) - [purgeable_memory.h](purgeable__memory_8h.md)
- [usb_ddk_api.h](usb__ddk__api_8h.md)
- [usb_ddk_types.h](usb__ddk__types_8h.md)
- [trace.h](trace_8h.md)
- Structs - Structs
- [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md) - [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md)
- [OH_NativeBuffer_Config](_o_h___native_buffer___config.md) - [OH_NativeBuffer_Config](_o_h___native_buffer___config.md)
...@@ -132,3 +137,14 @@ ...@@ -132,3 +137,14 @@
- [OH_Rdb_Store](_o_h___rdb___store.md) - [OH_Rdb_Store](_o_h___rdb___store.md)
- [OH_VBucket](_o_h___v_bucket.md) - [OH_VBucket](_o_h___v_bucket.md)
- [OH_VObject](_o_h___v_object.md) - [OH_VObject](_o_h___v_object.md)
- [UsbConfigDescriptor](_usb_config_descriptor.md)
- [UsbControlRequestSetup](_usb_control_request_setup.md)
- [UsbDdkConfigDescriptor](_usb_ddk_config_descriptor.md)
- [UsbDdkEndpointDescriptor](_usb_ddk_endpoint_descriptor.md)
- [UsbDdkInterface](_usb_ddk_interface.md)
- [UsbDdkInterfaceDescriptor](_usb_ddk_interface_descriptor.md)
- [UsbDeviceDescriptor](_usb_device_descriptor.md)
- [UsbDeviceMemMap](_usb_device_mem_map.md)
- [UsbEndpointDescriptor](_usb_endpoint_descriptor.md)
- [UsbInterfaceDescriptor](_usb_interface_descriptor.md)
- [UsbRequestPipe](_usb_request_pipe.md)
# UsbConfigDescriptor
## Overview
Defines standard configuration descriptors, which correspond to **Standard Configuration Descriptor** in the USB protocol.
**Since**
10
**Related Modules**
[UsbDdk](_usb_ddk.md)
## Summary
### Member Variables
| Name| Description|
| -------- | -------- |
| [bLength](#blength) | Size of the descriptor, in bytes.|
| [bDescriptorType](#bdescriptortype) | Descriptor type.|
| [wTotalLength](#wtotallength) | Total length of the configuration descriptor, including the configuration, interface, endpoint, and class- or vendor-specific descriptors.|
| [bNumInterfaces](#bnuminterfaces) | Number of interfaces supported by the configuration.|
| [bConfigurationValue](#bconfigurationvalue) | Configuration index, which is used to select the configuration.|
| [iConfiguration](#iconfiguration) | Index of the string descriptor that describes the configuration.|
| [bmAttributes](#bmattributes) | Configuration attributes, including the power mode and remote wakeup.|
| [bMaxPower](#bmaxpower) | Maximum power consumption of the bus-powered USB device, in 2 mA.|
## Member Variable Description
### bConfigurationValue
```
uint8_t UsbConfigDescriptor::bConfigurationValue
```
**Description**
Configuration index, which is used to select the configuration.
### bDescriptorType
```
uint8_t UsbConfigDescriptor::bDescriptorType
```
**Description**
Descriptor type.
### bLength
```
uint8_t UsbConfigDescriptor::bLength
```
**Description**
Size of the descriptor, in bytes.
### bmAttributes
```
uint8_t UsbConfigDescriptor::bmAttributes
```
**Description**
Configuration attributes, including the power mode and remote wakeup.
### bMaxPower
```
uint8_t UsbConfigDescriptor::bMaxPower
```
**Description**
Maximum power consumption of the bus-powered USB device, in 2 mA.
### bNumInterfaces
```
uint8_t UsbConfigDescriptor::bNumInterfaces
```
**Description**
Number of interfaces supported by the configuration.
### iConfiguration
```
uint8_t UsbConfigDescriptor::iConfiguration
```
**Description**
Index of the string descriptor that describes the configuration.
### wTotalLength
```
uint16_t UsbConfigDescriptor::wTotalLength
```
**Description**
Total length of the configuration descriptor, including the configuration, interface, endpoint, and class- or vendor-specific descriptors.
# UsbControlRequestSetup
## Overview
Defines the setup data for control transfer, which corresponds to <b>Setup Data</b> in the USB protocol.
**Since**
10
**Related Modules**
[UsbDdk](_usb_ddk.md)
## Summary
### Member Variables
| Name| Description|
| -------- | -------- |
| [bmRequestType](#bmrequesttype) | Request type.|
| [bRequest](#brequest) | Specific request.|
| [wValue](#wvalue) | Value corresponding to **wValue** in the USB protocol. Its meaning varies according to the request.|
| [wIndex](#windex) | Index corresponding to **wIndex** in the USB protocol. It is usually used to transfer the index or offset. Its meaning varies according to the request. |
| [wLength](#wlength) | Data length corresponding to **wLength** in the USB protocol. If data is transferred, this field indicates the number of transferred bytes.|
## Member Variable Description
### wIndex
```
uint16_t UsbControlRequestSetup::wIndex
```
**Description**
Index corresponding to **wIndex** in the USB protocol. It is usually used to transfer the index or offset. Its meaning varies according to the request.
### wLength
```
uint16_t UsbControlRequestSetup::wLength
```
**Description**
Data length corresponding to **wLength** in the USB protocol. If data is transferred, this field indicates the number of transferred bytes.
### bRequest
```
uint8_t UsbControlRequestSetup::bRequest
```
**Description**
Specific request.
### bmRequestType
```
uint8_t UsbControlRequestSetup::bmRequestType
```
**Description**
Request type.
### wValue
```
uint16_t UsbControlRequestSetup::wValue
```
**Description**
Value corresponding to **wValue** in the USB protocol. Its meaning varies according to the request.
# UsbDdk
## Overview
Provides USB DDK APIs to open and close USB interfaces, perform non-isochronous and isochronous data transfer over USB pipes, and implement control transfer and interrupt transfer, etc.
\@syscap SystemCapability.Driver.USB.Extension
**Since**
10
## Summary
### File
| Name| Description|
| -------- | -------- |
| [usb_ddk_api.h](usb__ddk__api_8h.md) | Declares the USB DDK APIs used by the USB host to access USB devices.<br>File to include: &lt;usb/usb_ddk_api.h&gt;|
| [usb_ddk_types.h](usb__ddk__types_8h.md) | Provides the enumerated variables, structures, and macros used in USB DDK APIs.<br>File to include: &lt;usb/usb_ddk_types.h&gt; |
### Structs
| Name| Description|
| -------- | -------- |
| [UsbControlRequestSetup](_usb_control_request_setup.md) | Setup data for control transfer. It corresponds to **Setup Data** in the USB protocol.|
| [UsbDeviceDescriptor](_usb_device_descriptor.md) | Standard device descriptor, corresponding to **Standard Device Descriptor** in the USB protocol.|
| [UsbConfigDescriptor](_usb_config_descriptor.md) | Standard configuration descriptor, corresponding to **Standard Configuration Descriptor** in the USB protocol.|
| [UsbInterfaceDescriptor](_usb_interface_descriptor.md) | Standard interface descriptor, corresponding to **Standard Interface Descriptor** in the USB protocol.|
| [UsbEndpointDescriptor](_usb_endpoint_descriptor.md) | Standard endpoint descriptor, corresponding to **Standard Endpoint Descriptor** in the USB protocol.|
| [UsbDdkEndpointDescriptor](_usb_ddk_endpoint_descriptor.md) | Endpoint descriptor.|
| [UsbDdkInterfaceDescriptor](_usb_ddk_interface_descriptor.md) | Interface descriptor.|
| [UsbDdkInterface](_usb_ddk_interface.md) | USB DDK interface, which is a collection of alternate settings for a particular USB interface.|
| [UsbDdkConfigDescriptor](_usb_ddk_config_descriptor.md) | Configuration descriptor.|
| [UsbRequestPipe](_usb_request_pipe.md) | Request pipe.|
| [UsbDeviceMemMap](_usb_device_mem_map.md) | Device memory map created by calling [OH_Usb_CreateDeviceMemMap()](#oh_usb_createdevicememmap). A buffer using the device memory map can provide better performance.|
### Types
| Name| Description|
| -------- | -------- |
| [UsbDdkEndpointDescriptor](#usbddkendpointdescriptor) | Endpoint descriptor.|
| [UsbDdkInterfaceDescriptor](#usbddkinterfacedescriptor) | Interface descriptor.|
| [UsbDdkInterface](#usbddkinterface) | USB DDK interface, which is a collection of alternate settings for a particular USB interface.|
| [UsbDdkConfigDescriptor](#usbddkconfigdescriptor) | Configuration descriptor.|
| [UsbDeviceMemMap](#usbdevicememmap) | Device memory map created by calling [OH_Usb_CreateDeviceMemMap()](#oh_usb_createdevicememmap). A buffer using the device memory map can provide better performance.|
### Enums
| Name| Description|
| -------- | -------- |
| [UsbDdkErrCode](#usbddkerrcode) {<br>USB_DDK_SUCCESS = 0, USB_DDK_FAILED = -1, USB_DDK_INVALID_PARAMETER = -2, USB_DDK_MEMORY_ERROR = -3,<br>USB_DDK_INVALID_OPERATION = -4, USB_DDK_NULL_PTR = -5, USB_DDK_DEVICE_BUSY = -6, USB_DDK_TIMEOUT = -7<br>} | USB DDK error code definitions.|
### Functions
| Name| Description|
| -------- | -------- |
| [OH_Usb_Init](#oh_usb_init) (void) | Initializes the DDK.|
| [OH_Usb_Release](#oh_usb_release) (void) | Releases the DDK.|
| [OH_Usb_GetDeviceDescriptor](#oh_usb_getdevicedescriptor) (uint64_t deviceId, struct [UsbDeviceDescriptor](_usb_device_descriptor.md) \*desc) | Obtains the device descriptor.|
| [OH_Usb_GetConfigDescriptor](#oh_usb_getconfigdescriptor) (uint64_t deviceId, uint8_t configIndex, struct [UsbDdkConfigDescriptor](_usb_ddk_config_descriptor.md) \*\*const config) | Obtains the configuration descriptor. To avoid memory leakage, use **OH_Usb_FreeConfigDescriptor** to release a descriptor after use.|
| [OH_Usb_FreeConfigDescriptor](#oh_usb_freeconfigdescriptor) (const struct [UsbDdkConfigDescriptor](_usb_ddk_config_descriptor.md) \*const config) | Releases the configuration descriptor. To avoid memory leakage, release a descriptor after use.|
| [OH_Usb_ClaimInterface](#oh_usb_claiminterface) (uint64_t deviceId, uint8_t interfaceIndex, uint64_t \*[interfaceHandle](usb__ddk__types_8h.md#interfacehandle)) | Declares a USB interface.|
| [OH_Usb_ReleaseInterface](#oh_usb_releaseinterface) (uint64_t [interfaceHandle](usb__ddk__types_8h.md#interfacehandle)) | Releases a USB interface.|
| [OH_Usb_SelectInterfaceSetting](#oh_usb_selectinterfacesetting) (uint64_t [interfaceHandle](usb__ddk__types_8h.md#interfacehandle), uint8_t settingIndex) | Activates the alternate setting of a USB interface.|
| [OH_Usb_GetCurrentInterfaceSetting](#oh_usb_getcurrentinterfacesetting) (uint64_t [interfaceHandle](usb__ddk__types_8h.md#interfacehandle), uint8_t \*settingIndex) | Obtains the activated alternate setting of a USB interface.|
| [OH_Usb_SendControlReadRequest](#oh_usb_sendcontrolreadrequest) (uint64_t [interfaceHandle](usb__ddk__types_8h.md#interfacehandle), const struct [UsbControlRequestSetup](_usb_control_request_setup.md) \*setup, uint32_t [timeout](usb__ddk__types_8h.md#timeout), uint8_t \*data, uint32_t \*dataLen) | Sends a control read transfer request. This API works in a synchronous manner.|
| [OH_Usb_SendControlWriteRequest](#oh_usb_sendcontrolwriterequest) (uint64_t [interfaceHandle](usb__ddk__types_8h.md#interfacehandle), const struct [UsbControlRequestSetup](_usb_control_request_setup.md) \*setup, uint32_t [timeout](usb__ddk__types_8h.md#timeout), const uint8_t \*data, uint32_t dataLen) | Sends a control write transfer request. This API works in a synchronous manner.|
| [OH_Usb_SendPipeRequest](#oh_usb_sendpiperequest) (const struct [UsbRequestPipe](_usb_request_pipe.md) \*pipe, [UsbDeviceMemMap](_usb_device_mem_map.md) \*devMmap) | Sends a pipe request. This API works in a synchronous manner. It applies to interrupt transfer and bulk transfer.|
| [OH_Usb_CreateDeviceMemMap](#oh_usb_createdevicememmap) (uint64_t deviceId, size_t size, [UsbDeviceMemMap](_usb_device_mem_map.md) \*\*devMmap) | Creates a buffer. To avoid memory leakage, use [OH_Usb_DestroyDeviceMemMap()](#oh_usb_destroydevicememmap) to destroy a buffer after use.|
| [OH_Usb_DestroyDeviceMemMap](#oh_usb_destroydevicememmap) ([UsbDeviceMemMap](_usb_device_mem_map.md) \*devMmap) | Destroys a buffer. To avoid resource leakage, destroy a buffer in time after use.|
## Type Description
### UsbDdkConfigDescriptor
```
typedef struct UsbDdkConfigDescriptor UsbDdkConfigDescriptor
```
**Description**
Configuration descriptor.
### UsbDdkEndpointDescriptor
```
typedef struct UsbDdkEndpointDescriptor UsbDdkEndpointDescriptor
```
**Description**
Endpoint descriptor.
### UsbDdkInterface
```
typedef struct UsbDdkInterface UsbDdkInterface
```
**Description**
USB DDK interface, which is a collection of alternate settings for a particular USB interface.
### UsbDdkInterfaceDescriptor
```
typedef struct UsbDdkInterfaceDescriptor UsbDdkInterfaceDescriptor
```
**Description**
Interface descriptor.
### UsbDeviceMemMap
```
typedef struct UsbDeviceMemMap UsbDeviceMemMap
```
**Description**
Device memory map created by calling [OH_Usb_CreateDeviceMemMap()](#oh_usb_createdevicememmap). A buffer using the device memory map can provide better performance.
## Enum Description
### UsbDdkErrCode
```
enum UsbDdkErrCode
```
**Description**
USB DDK error code definitions.
| Value| Description|
| -------- | -------- |
| USB_DDK_SUCCESS | Operation successful.|
| USB_DDK_FAILED | Operation failed.|
| USB_DDK_INVALID_PARAMETER | Invalid parameter.|
| USB_DDK_MEMORY_ERROR | Memory-related error, for example, insufficient memory, memory data copy failure, or memory application failure.|
| USB_DDK_INVALID_OPERATION | Invalid operation.|
| USB_DDK_NULL_PTR | Null pointer.|
| USB_DDK_DEVICE_BUSY | Device busy.|
| USB_DDK_TIMEOUT | Transfer timed out.|
## Function Description
### OH_Usb_ClaimInterface()
```
int32_t OH_Usb_ClaimInterface (uint64_t deviceId, uint8_t interfaceIndex, uint64_t * interfaceHandle )
```
**Description**
Declares a USB interface.
**Parameters**
| Name| Description|
| -------- | -------- |
| deviceId | Device ID.|
| interfaceIndex | Interface index, which corresponds to [bInterfaceNumber](_usb_interface_descriptor.md#binterfacenumber) in the USB protocol.|
| interfaceHandle | Interface operation handle. After the interface is claimed successfully, a value will be assigned to this parameter.|
**Returns**
**0** if the operation is successful; a negative value otherwise.
### OH_Usb_CreateDeviceMemMap()
```
int32_t OH_Usb_CreateDeviceMemMap (uint64_t deviceId, size_t size, UsbDeviceMemMap ** devMmap )
```
**Description**
Creates a buffer. To avoid memory leakage, use [OH_Usb_DestroyDeviceMemMap()](#oh_usb_destroydevicememmap) to destroy a buffer after use.
**Parameters**
| Name| Description|
| -------- | -------- |
| deviceId | Device ID.|
| size | Buffer size.|
| devMmap | Data memory map, through which the created buffer is returned to the caller.|
**Returns**
**0** if the operation is successful; a negative value otherwise.
### OH_Usb_DestroyDeviceMemMap()
```
void OH_Usb_DestroyDeviceMemMap (UsbDeviceMemMap * devMmap)
```
**Description**
Destroys a buffer. To avoid resource leakage, destroy a buffer in time after use.
**Parameters**
| Name| Description|
| -------- | -------- |
| devMmap | Destroys the buffer created by [OH_Usb_CreateDeviceMemMap()](#oh_usb_createdevicememmap).|
### OH_Usb_FreeConfigDescriptor()
```
void OH_Usb_FreeConfigDescriptor (const struct UsbDdkConfigDescriptor *const config)
```
**Description**
Releases the configuration descriptor. To avoid memory leakage, use **OH_Usb_FreeConfigDescriptor** to release a descriptor after use.
**Parameters**
| Name| Description|
| -------- | -------- |
| config | Configuration descriptor obtained by calling [OH_Usb_GetConfigDescriptor()](#oh_usb_getconfigdescriptor).|
### OH_Usb_GetConfigDescriptor()
```
int32_t OH_Usb_GetConfigDescriptor (uint64_t deviceId, uint8_t configIndex, struct UsbDdkConfigDescriptor **const config )
```
**Description**
Obtains the configuration descriptor. To avoid memory leakage, use **OH_Usb_FreeConfigDescriptor** to release a descriptor after use.
**Parameters**
| Name| Description|
| -------- | -------- |
| deviceId | Device ID.|
| configIndex | Configuration ID, which corresponds to [bConfigurationValue](_usb_config_descriptor.md#bconfigurationvalue) in the USB protocol.|
| config | Configuration descriptor, which includes the standard configuration descriptor defined in the USB protocol and the associated interface descriptor and endpoint descriptor.|
**Returns**
**0** if the operation is successful; a negative value otherwise.
### OH_Usb_GetCurrentInterfaceSetting()
```
int32_t OH_Usb_GetCurrentInterfaceSetting (uint64_t interfaceHandle, uint8_t * settingIndex )
```
**Description**
Obtains the activated alternate setting of a USB interface.
**Parameters**
| Name| Description|
| -------- | -------- |
| interfaceHandle | Interface operation handle.|
| settingIndex | Index of the alternate setting, which corresponds to [bAlternateSetting](_usb_interface_descriptor.md#balternatesetting) in the USB protocol.|
**Returns**
**0** if the operation is successful; a negative value otherwise.
### OH_Usb_GetDeviceDescriptor()
```
int32_t OH_Usb_GetDeviceDescriptor (uint64_t deviceId, struct UsbDeviceDescriptor * desc )
```
**Description**
Obtains the device descriptor.
**Parameters**
| Name| Description|
| -------- | -------- |
| deviceId | Device ID.|
| desc | Device descriptor. For details, see [UsbDeviceDescriptor](_usb_device_descriptor.md).|
**Returns**
**0** if the operation is successful; a negative value otherwise.
### OH_Usb_Init()
```
int32_t OH_Usb_Init (void )
```
**Description**
Initializes the DDK.
**Returns**
**0** if the operation is successful; a negative value otherwise.
### OH_Usb_Release()
```
void OH_Usb_Release (void )
```
**Description**
Releases the DDK.
### OH_Usb_ReleaseInterface()
```
int32_t OH_Usb_ReleaseInterface (uint64_t interfaceHandle)
```
**Description**
Releases a USB interface.
**Parameters**
| Name| Description|
| -------- | -------- |
| interfaceHandle | Interface operation handle.|
**Returns**
**0** if the operation is successful; a negative value otherwise.
### OH_Usb_SelectInterfaceSetting()
```
int32_t OH_Usb_SelectInterfaceSetting (uint64_t interfaceHandle, uint8_t settingIndex )
```
**Description**
Activates the alternate setting of a USB interface.
**Parameters**
| Name| Description|
| -------- | -------- |
| interfaceHandle | Interface operation handle.|
| settingIndex | Index of the alternate setting, which corresponds to [bAlternateSetting](_usb_interface_descriptor.md#balternatesetting) in the USB protocol.|
**Returns**
**0** if the operation is successful; a negative value otherwise.
### OH_Usb_SendControlReadRequest()
```
int32_t OH_Usb_SendControlReadRequest (uint64_t interfaceHandle, const struct UsbControlRequestSetup * setup, uint32_t timeout, uint8_t * data, uint32_t * dataLen )
```
**Description**
Sends a control read transfer request. This API works in a synchronous manner.
**Parameters**
| Name| Description|
| -------- | -------- |
| interfaceHandle | Interface operation handle.|
| setup | Request parameters. For details, see [UsbControlRequestSetup](_usb_control_request_setup.md).|
| timeout | Timeout duration, in milliseconds.|
| data | Data to be transferred.|
| dataLen | Data length. The return value indicates the length of the actually read data.|
**Returns**
**0** if the operation is successful; a negative value otherwise.
### OH_Usb_SendControlWriteRequest()
```
int32_t OH_Usb_SendControlWriteRequest (uint64_t interfaceHandle, const struct UsbControlRequestSetup * setup, uint32_t timeout, const uint8_t * data, uint32_t dataLen )
```
**Description**
Sends a control write transfer request. This API works in a synchronous manner.
**Parameters**
| Name| Description|
| -------- | -------- |
| interfaceHandle | Interface operation handle.|
| setup | Request parameters. For details, see [UsbControlRequestSetup](_usb_control_request_setup.md).|
| timeout | Timeout duration, in milliseconds.|
| data | Data to be transferred.|
| dataLen | Data length.|
**Returns**
**0** if the operation is successful; a negative value otherwise.
### OH_Usb_SendPipeRequest()
```
int32_t OH_Usb_SendPipeRequest (const struct UsbRequestPipe * pipe, UsbDeviceMemMap * devMmap )
```
**Description**
Sends a pipe request. This API works in a synchronous manner. It applies to interrupt transfer and bulk transfer.
**Parameters**
| Name| Description|
| -------- | -------- |
| pipe | Pipe used to transfer data.|
| devMmap | Device memory map, which can be obtained by calling [OH_Usb_CreateDeviceMemMap()](#oh_usb_createdevicememmap).|
**Returns**
**0** if the operation is successful; a negative value otherwise.
# UsbDdkConfigDescriptor
## Overview
Defines configuration descriptors.
**Since**
10
**Related Modules**
[UsbDdk](_usb_ddk.md)
## Summary
### Member Variables
| Name| Description|
| -------- | -------- |
| [configDescriptor](#configdescriptor) | Standard configuration descriptor.|
| [interface](#interface) | Interfaces contained in the configuration.|
| [extra](#extra) | Unresolved descriptor, including class- or vendor-specific descriptors.|
| [extraLength](#extralength) | Length of the unresolved descriptor.|
## Member Variable Description
### configDescriptor
```
struct UsbConfigDescriptor UsbDdkConfigDescriptor::configDescriptor
```
**Description**
Standard configuration descriptor.
### extra
```
uint8_t* UsbDdkConfigDescriptor::extra
```
**Description**
Unresolved descriptor, including class- or vendor-specific descriptors.
### extraLength
```
uint32_t UsbDdkConfigDescriptor::extraLength
```
**Description**
Length of the unresolved descriptor.
### interface
```
struct UsbDdkInterface* UsbDdkConfigDescriptor::interface
```
**Description**
Interfaces contained in the configuration.
# UsbDdkEndpointDescriptor
## Overview
Defines endpoint descriptors.
**Since**
10
**Related Modules**
[UsbDdk](_usb_ddk.md)
## Summary
### Member Variables
| Name| Description|
| -------- | -------- |
| [endpointDescriptor](#endpointdescriptor) | Standard endpoint descriptor.|
| [extra](#extra) | Unresolved descriptor, including class- or vendor-specific descriptors.|
| [extraLength](#extralength) | Length of the unresolved descriptor.|
## Member Variable Description
### endpointDescriptor
```
struct UsbEndpointDescriptor UsbDdkEndpointDescriptor::endpointDescriptor
```
**Description**
Standard endpoint descriptor.
### extra
```
uint8_t* UsbDdkEndpointDescriptor::extra
```
**Description**
Unresolved descriptor, including class- or vendor-specific descriptors.
### extraLength
```
uint32_t UsbDdkEndpointDescriptor::extraLength
```
**Description**
Length of the unresolved descriptor.
# UsbDdkInterface
## Overview
Defines a USB DDK interface, which is a collection of alternate settings for a particular USB interface.
**Since**
10
**Related Modules**
[UsbDdk](_usb_ddk.md)
## Summary
### Member Variables
| Name| Description|
| -------- | -------- |
| [numAltsetting](#numaltsetting) | Number of alternate settings of the interface.|
| [altsetting](#altsetting) | Alternate setting of the interface.|
## Member Variable Description
### altsetting
```
struct UsbDdkInterfaceDescriptor* UsbDdkInterface::altsetting
```
**Description**
Alternate setting of the interface.
### numAltsetting
```
uint8_t UsbDdkInterface::numAltsetting
```
**Description**
Number of alternate settings of the interface.
# UsbDdkInterfaceDescriptor
## Overview
Defines interface descriptors.
**Since**
10
**Related Modules**
[UsbDdk](_usb_ddk.md)
## Summary
### Member Variables
| Name| Description|
| -------- | -------- |
| [interfaceDescriptor](#interfacedescriptor) | Standard interface descriptor.|
| [endPoint](#endpoint) | Endpoint descriptor contained in the interface.|
| [extra](#extra) | Unresolved descriptor, including class- or vendor-specific descriptors.|
| [extraLength](#extralength) | Length of the unresolved descriptor.|
## Member Variable Description
### endPoint
```
struct UsbDdkEndpointDescriptor* UsbDdkInterfaceDescriptor::endPoint
```
**Description**
Endpoint descriptor contained in the interface.
### extra
```
uint8_t* UsbDdkInterfaceDescriptor::extra
```
**Description**
Unresolved descriptor, including class- or vendor-specific descriptors.
### extraLength
```
uint32_t UsbDdkInterfaceDescriptor::extraLength
```
**Description**
Length of the unresolved descriptor.
### interfaceDescriptor
```
struct UsbInterfaceDescriptor UsbDdkInterfaceDescriptor::interfaceDescriptor
```
**Description**
Standard interface descriptor.
# UsbDeviceDescriptor
## Overview
Defines standard device descriptors, which correspond to **Standard Device Descriptor** in the USB protocol.
**Since**
10
**Related Modules**
[UsbDdk](_usb_ddk.md)
## Summary
### Member Variables
| Name| Description|
| -------- | -------- |
| [bLength](#blength) | Size of the descriptor, in bytes.|
| [bDescriptorType](#bdescriptortype) | Descriptor type.|
| [bcdUSB](#bcdusb) | USB protocol release number.|
| [bDeviceClass](#bdeviceclass) | Interface class code allocated by the USB-IF.|
| [bDeviceSubClass](#bdevicesubclass) | Device subclass code allocated by USB-IF. The value is limited by that of bDeviceClass.|
| [bDeviceProtocol](#bdeviceprotocol) | Protocol code allocated by USB-IF. The value is limited by that of [bDeviceClass](#bdeviceclass) and [bDeviceSubClass](#bdevicesubclass).|
| [bMaxPacketSize0](#bmaxpacketsize0) | Maximum packet size of endpoint 0. Only values 8, 16, 32, and 64 are valid.|
| [idVendor](#idvendor) | Vendor ID allocated by USB-IF.|
| [idProduct](#idproduct) | Product ID allocated by the vendor.|
| [bcdDevice](#bcddevice) | Device release number.|
| [iManufacturer](#imanufacturer) | Index of the string descriptor that describes the vendor.|
| [iProduct](#iproduct) | Index of the string descriptor that describes the product.|
| [iSerialNumber](#iserialnumber) | Index of the string descriptor that describes the device SN.|
| [bNumConfigurations](#bnumconfigurations) | Configuration quantity.|
## Member Variable Description
### bcdDevice
```
uint16_t UsbDeviceDescriptor::bcdDevice
```
**Description**
Device release number.
### bcdUSB
```
uint16_t UsbDeviceDescriptor::bcdUSB
```
**Description**
USB protocol release number.
### bDescriptorType
```
uint8_t UsbDeviceDescriptor::bDescriptorType
```
**Description**
Descriptor type.
### bDeviceClass
```
uint8_t UsbDeviceDescriptor::bDeviceClass
```
**Description**
Interface class code allocated by the USB-IF.
### bDeviceProtocol
```
uint8_t UsbDeviceDescriptor::bDeviceProtocol
```
**Description**
Protocol code allocated by USB-IF. The value is limited by that of [bDeviceClass](#bdeviceclass) and [bDeviceSubClass](#bdevicesubclass).
### bDeviceSubClass
```
uint8_t UsbDeviceDescriptor::bDeviceSubClass
```
**Description**
Device subclass code allocated by USB-IF. The value is limited by that of bDeviceClass.
### bLength
```
uint8_t UsbDeviceDescriptor::bLength
```
**Description**
Size of the descriptor, in bytes.
### bMaxPacketSize0
```
uint8_t UsbDeviceDescriptor::bMaxPacketSize0
```
**Description**
Maximum packet size of endpoint 0. Only values 8, 16, 32, and 64 are valid.
### bNumConfigurations
```
uint8_t UsbDeviceDescriptor::bNumConfigurations
```
**Description**
Configuration quantity.
### idProduct
```
uint16_t UsbDeviceDescriptor::idProduct
```
**Description**
Product ID allocated by the vendor.
### idVendor
```
uint16_t UsbDeviceDescriptor::idVendor
```
**Description**
Vendor ID allocated by USB-IF.
### iManufacturer
```
uint8_t UsbDeviceDescriptor::iManufacturer
```
**Description**
Index of the string descriptor that describes the vendor.
### iProduct
```
uint8_t UsbDeviceDescriptor::iProduct
```
**Description**
Index of the string descriptor that describes the product.
### iSerialNumber
```
uint8_t UsbDeviceDescriptor::iSerialNumber
```
**Description**
Index of the string descriptor that describes the device SN.
# UsbDeviceMemMap
## Overview
Device memory map created by calling [OH_Usb_CreateDeviceMemMap()](_usb_ddk.md#oh_usb_createdevicememmap). A buffer using the device memory map can provide better performance.
**Since**
10
**Related Modules**
[UsbDdk](_usb_ddk.md)
## Summary
### Member Variables
| Name| Description|
| -------- | -------- |
| [address](#address) | Buffer address.|
| [size](#size) | Buffer size.|
| [offset](#offset) | Offset of the used buffer. The default value is 0, indicating that there is no offset and the buffer starts from the specified address.|
| [bufferLength](#bufferlength) | Length of the used buffer. By default, the value is equal to the size, indicating that the entire buffer is used.|
| [transferedLength](#transferedlength) | Length of the transferred data.|
## Member Variable Description
### address
```
uint8_t* const UsbDeviceMemMap::address
```
**Description**
Buffer address.
### bufferLength
```
uint32_t UsbDeviceMemMap::bufferLength
```
**Description**
Length of the used buffer. By default, the value is equal to the size, indicating that the entire buffer is used.
### offset
```
uint32_t UsbDeviceMemMap::offset
```
**Description**
Offset of the used buffer. The default value is 0, indicating that there is no offset and the buffer starts from the specified address.
### size
```
const size_t UsbDeviceMemMap::size
```
**Description**
Buffer size.
### transferedLength
```
uint32_t UsbDeviceMemMap::transferedLength
```
**Description**
Length of the transferred data.
# UsbEndpointDescriptor
## Overview
Defines standard endpoint descriptors, which correspond to **Standard Endpoint Descriptor** in the USB protocol.
**Since**
10
**Related Modules**
[UsbDdk](_usb_ddk.md)
## Summary
### Member Variables
| Name| Description|
| -------- | -------- |
| [bLength](#blength) | Size of the descriptor, in bytes.|
| [bDescriptorType](#bdescriptortype) | Descriptor type.|
| [bEndpointAddress](#bendpointaddress) | Endpoint address, including the endpoint number and endpoint direction.|
| [bmAttributes](#bmattributes) | Endpoint attributes, including the transfer type, synchronization type, and usage type.|
| [wMaxPacketSize](#wmaxpacketsize) | Maximum packet size supported by an endpoint.|
| [bInterval](#binterval) | Interval for polling endpoints for data transfer.|
| [bRefresh](#brefresh) | Refresh rate for audio devices.|
| [bSynchAddress](#bsynchaddress) | Endpoint synchronization address for audio devices.|
## Member Variable Description
### bDescriptorType
```
uint8_t UsbEndpointDescriptor::bDescriptorType
```
**Description**
Descriptor type.
### bEndpointAddress
```
uint8_t UsbEndpointDescriptor::bEndpointAddress
```
**Description**
Endpoint address, including the endpoint number and endpoint direction.
### bInterval
```
uint8_t UsbEndpointDescriptor::bInterval
```
**Description**
Interval for polling endpoints for data transfer.
### bLength
```
uint8_t UsbEndpointDescriptor::bLength
```
**Description**
Size of the descriptor, in bytes.
### bmAttributes
```
uint8_t UsbEndpointDescriptor::bmAttributes
```
**Description**
Endpoint attributes, including the transfer type, synchronization type, and usage type.
### bRefresh
```
uint8_t UsbEndpointDescriptor::bRefresh
```
**Description**
Refresh rate for audio devices.
### bSynchAddress
```
uint8_t UsbEndpointDescriptor::bSynchAddress
```
**Description**
Endpoint synchronization address for audio devices.
### wMaxPacketSize
```
uint16_t UsbEndpointDescriptor::wMaxPacketSize
```
**Description**
Maximum packet size supported by an endpoint.
# UsbInterfaceDescriptor
## Overview
Defines standard interface descriptors, which correspond to **Standard Interface Descriptor** in the USB protocol.
**Since**
10
**Related Modules**
[UsbDdk](_usb_ddk.md)
## Summary
### Member Variables
| Name| Description|
| -------- | -------- |
| [bLength](#blength) | Size of the descriptor, in bytes.|
| [bDescriptorType](#bdescriptortype) | Descriptor type.|
| [bInterfaceNumber](#binterfacenumber) | Interface ID.|
| [bAlternateSetting](#balternatesetting) | Value used to select the alternate setting of the interface.|
| [bNumEndpoints](#bnumendpoints) | Number of endpoints (excluding endpoint 0) used by the interface.|
| [bInterfaceClass](#binterfaceclass) | Interface class code allocated by the USB-IF.|
| [bInterfaceSubClass](#binterfacesubclass) | Device subclass code allocated by USB-IF. The value is limited by that of [bInterfaceClass](#binterfaceclass).|
| [bInterfaceProtocol](#binterfaceprotocol) | Protocol code allocated by USB-IF. The value is limited by that of [bInterfaceClass](#binterfaceclass) and [bInterfaceSubClass](#binterfacesubclass).|
| [iInterface](#iinterface) | Index of the string descriptor that describes the interface.|
## Member Variable Description
### bAlternateSetting
```
uint8_t UsbInterfaceDescriptor::bAlternateSetting
```
**Description**
Value used to select the alternate setting of the interface.
### bDescriptorType
```
uint8_t UsbInterfaceDescriptor::bDescriptorType
```
**Description**
Descriptor type.
### bInterfaceClass
```
uint8_t UsbInterfaceDescriptor::bInterfaceClass
```
**Description**
Interface class code allocated by the USB-IF.
### bInterfaceNumber
```
uint8_t UsbInterfaceDescriptor::bInterfaceNumber
```
**Description**
Interface ID.
### bInterfaceProtocol
```
uint8_t UsbInterfaceDescriptor::bInterfaceProtocol
```
**Description**
Protocol code allocated by USB-IF. The value is limited by that of [bInterfaceClass](#binterfaceclass) and [bInterfaceSubClass](#binterfacesubclass).
### bInterfaceSubClass
```
uint8_t UsbInterfaceDescriptor::bInterfaceSubClass
```
**Description**
Device subclass code allocated by USB-IF. The value is limited by that of [bInterfaceClass](#binterfaceclass).
### bLength
```
uint8_t UsbInterfaceDescriptor::bLength
```
**Description**
Size of the descriptor, in bytes.
### bNumEndpoints
```
uint8_t UsbInterfaceDescriptor::bNumEndpoints
```
**Description**
Number of endpoints (excluding endpoint 0) used by the interface.
### iInterface
```
uint8_t UsbInterfaceDescriptor::iInterface
```
**Description**
Index of the string descriptor that describes the interface.
# UsbRequestPipe
## Overview
Defines a request pipe.
**Since**
10
**Related Modules**
[UsbDdk](_usb_ddk.md)
## Summary
### Member Variables
| Name| Description|
| -------- | -------- |
| [interfaceHandle](#interfacehandle) | Interface operation handle.|
| [endpoint](#endpoint) | Endpoint address.|
| [timeout](#timeout) | Timeout duration, in milliseconds.|
## Member Variable Description
### endpoint
```
uint8_t UsbRequestPipe::endpoint
```
**Description**
Endpoint address.
### interfaceHandle
```
uint64_t UsbRequestPipe::interfaceHandle
```
**Description**
Interface operation handle.
### timeout
```
uint32_t UsbRequestPipe::timeout
```
**Description**
Timeout duration, in milliseconds.
# usb_ddk_api.h
## Overview
Declares the USB DDK APIs used by the USB host to access USB devices.
**Since**
10
**Related Modules**
[UsbDdk](_usb_ddk.md)
## Summary
### Functions
| Name| Description|
| -------- | -------- |
| [OH_Usb_Init](_usb_ddk.md#oh_usb_init)&nbsp;(void) | Initializes the DDK.|
| [OH_Usb_Release](_usb_ddk.md#oh_usb_release)&nbsp;(void) | Releases the DDK.|
| [OH_Usb_GetDeviceDescriptor](_usb_ddk.md#oh_usb_getdevicedescriptor)&nbsp;(uint64_t&nbsp;deviceId,&nbsp;struct&nbsp;[UsbDeviceDescriptor](_usb_device_descriptor.md)&nbsp;\*desc) | Obtains the device descriptor.|
| [OH_Usb_GetConfigDescriptor](_usb_ddk.md#oh_usb_getconfigdescriptor)&nbsp;(uint64_t&nbsp;deviceId,&nbsp;uint8_t&nbsp;configIndex,&nbsp;struct&nbsp;[UsbDdkConfigDescriptor](_usb_ddk_config_descriptor.md)&nbsp;\*\*const&nbsp;config) | Obtains the configuration descriptor. To avoid memory leakage, use [OH_Usb_FreeConfigDescriptor()](_usb_ddk.md#oh_usb_freeconfigdescriptor) to release a descriptor after use.|
| [OH_Usb_FreeConfigDescriptor](_usb_ddk.md#oh_usb_freeconfigdescriptor)&nbsp;(const&nbsp;struct&nbsp;[UsbDdkConfigDescriptor](_usb_ddk_config_descriptor.md)&nbsp;\*const&nbsp;config) | Releases the configuration descriptor. To avoid memory leakage, release a descriptor after use.|
| [OH_Usb_ClaimInterface](_usb_ddk.md#oh_usb_claiminterface)&nbsp;(uint64_t&nbsp;deviceId,&nbsp;uint8_t&nbsp;interfaceIndex,&nbsp;uint64_t&nbsp;\*[interfaceHandle](usb__ddk__types_8h.md#interfacehandle)) | Declares a USB interface.|
| [OH_Usb_ReleaseInterface](_usb_ddk.md#oh_usb_releaseinterface)&nbsp;(uint64_t&nbsp;[interfaceHandle](usb__ddk__types_8h.md#interfacehandle)) | Releases a USB interface.|
| [OH_Usb_SelectInterfaceSetting](_usb_ddk.md#oh_usb_selectinterfacesetting)&nbsp;(uint64_t&nbsp;[interfaceHandle](usb__ddk__types_8h.md#interfacehandle),&nbsp;uint8_t&nbsp;settingIndex) | Activates the alternate setting of a USB interface.|
| [OH_Usb_GetCurrentInterfaceSetting](_usb_ddk.md#oh_usb_getcurrentinterfacesetting)&nbsp;(uint64_t&nbsp;[interfaceHandle](usb__ddk__types_8h.md#interfacehandle),&nbsp;uint8_t&nbsp;\*settingIndex) | Obtains the activated alternate setting of a USB interface.|
| [OH_Usb_SendControlReadRequest](_usb_ddk.md#oh_usb_sendcontrolreadrequest)&nbsp;(uint64_t&nbsp;[interfaceHandle](usb__ddk__types_8h.md#interfacehandle),&nbsp;const&nbsp;struct&nbsp;[UsbControlRequestSetup](_usb_control_request_setup.md)&nbsp;\*setup,&nbsp;uint32_t&nbsp;[timeout](usb__ddk__types_8h.md#timeout),&nbsp;uint8_t&nbsp;\*data,&nbsp;uint32_t&nbsp;\*dataLen) | Sends a control read transfer request. This API works in a synchronous manner.|
| [OH_Usb_SendControlWriteRequest](_usb_ddk.md#oh_usb_sendcontrolwriterequest)&nbsp;(uint64_t&nbsp;[interfaceHandle](usb__ddk__types_8h.md#interfacehandle),&nbsp;const&nbsp;struct&nbsp;[UsbControlRequestSetup](_usb_control_request_setup.md)&nbsp;\*setup,&nbsp;uint32_t&nbsp;[timeout](usb__ddk__types_8h.md#timeout),&nbsp;const&nbsp;uint8_t&nbsp;\*data,&nbsp;uint32_t&nbsp;dataLen) | Sends a control write transfer request. This API works in a synchronous manner.|
| [OH_Usb_SendPipeRequest](_usb_ddk.md#oh_usb_sendpiperequest)&nbsp;(const&nbsp;struct&nbsp;[UsbRequestPipe](_usb_request_pipe.md)&nbsp;\*pipe,&nbsp;[UsbDeviceMemMap](_usb_device_mem_map.md)&nbsp;\*devMmap) | Sends a pipe request. This API works in a synchronous manner. It applies to interrupt transfer and bulk transfer.|
| [OH_Usb_CreateDeviceMemMap](_usb_ddk.md#oh_usb_createdevicememmap)&nbsp;(uint64_t&nbsp;deviceId,&nbsp;size_t&nbsp;size,&nbsp;[UsbDeviceMemMap](_usb_device_mem_map.md)&nbsp;\*\*devMmap) | Creates a buffer. To avoid memory leakage, use [OH_Usb_DestroyDeviceMemMap()](_usb_ddk.md#oh_usb_destroydevicememmap) to destroy a buffer after use.|
| [OH_Usb_DestroyDeviceMemMap](_usb_ddk.md#oh_usb_destroydevicememmap)&nbsp;([UsbDeviceMemMap](_usb_device_mem_map.md)&nbsp;\*devMmap) | Destroys a buffer. To avoid resource leakage, destroy a buffer in time after use.|
# usb_ddk_types.h
## Overview
Provides the enumerated variables, structures, and macros used in USB DDK APIs.
**Since**
10
**Related Modules**
[UsbDdk](_usb_ddk.md)
## Summary
### Structs
| Name| Description|
| -------- | -------- |
| [UsbControlRequestSetup](_usb_control_request_setup.md) | Setup data for control transfer, corresponding to **Setup Data** in the USB protocol.|
| [UsbDeviceDescriptor](_usb_device_descriptor.md) | Standard device descriptor, corresponding to **Standard Device Descriptor** in the USB protocol.|
| [UsbConfigDescriptor](_usb_config_descriptor.md) | Standard configuration descriptor, corresponding to **Standard Configuration Descriptor** in the USB protocol.|
| [UsbInterfaceDescriptor](_usb_interface_descriptor.md) | Standard interface descriptor, corresponding to **Standard Interface Descriptor** in the USB protocol.|
| [UsbEndpointDescriptor](_usb_endpoint_descriptor.md) | Standard endpoint descriptor, corresponding to **Standard Endpoint Descriptor** in the USB protocol.|
| [UsbDdkEndpointDescriptor](_usb_ddk_endpoint_descriptor.md) | Endpoint descriptor.|
| [UsbDdkInterfaceDescriptor](_usb_ddk_interface_descriptor.md) | Interface descriptor.|
| [UsbDdkInterface](_usb_ddk_interface.md) | USB DDK interface, which is a collection of alternate settings for a particular USB interface.|
| [UsbDdkConfigDescriptor](_usb_ddk_config_descriptor.md) | Configuration descriptor.|
| [UsbRequestPipe](_usb_request_pipe.md) | Request pipe.|
| [UsbDeviceMemMap](_usb_device_mem_map.md) | Device memory map created by calling [OH_Usb_CreateDeviceMemMap()](_usb_ddk.md#oh_usb_createdevicememmap). A buffer using the device memory map can provide better performance.|
### Types
| Name| Description|
| -------- | -------- |
| [UsbDdkEndpointDescriptor](_usb_ddk.md#usbddkendpointdescriptor) | Endpoint descriptor.|
| [UsbDdkInterfaceDescriptor](_usb_ddk.md#usbddkinterfacedescriptor) | Interface descriptor.|
| [UsbDdkInterface](_usb_ddk.md#usbddkinterface) | USB interface.|
| [UsbDdkConfigDescriptor](_usb_ddk.md#usbddkconfigdescriptor) | Configuration descriptor.|
| [UsbDeviceMemMap](_usb_ddk.md#usbdevicememmap) | Device memory map created by calling [OH_Usb_CreateDeviceMemMap()](_usb_ddk.md#oh_usb_createdevicememmap). A buffer using the device memory map can provide better performance.|
### Enums
| Name| Description|
| -------- | -------- |
| [UsbDdkErrCode](_usb_ddk.md#usbddkerrcode)&nbsp;{<br>USB_DDK_SUCCESS&nbsp;=&nbsp;0,&nbsp;USB_DDK_FAILED&nbsp;=&nbsp;-1,&nbsp;USB_DDK_INVALID_PARAMETER&nbsp;=&nbsp;-2,&nbsp;USB_DDK_MEMORY_ERROR&nbsp;=&nbsp;-3,<br>USB_DDK_INVALID_OPERATION&nbsp;=&nbsp;-4,&nbsp;USB_DDK_NULL_PTR&nbsp;=&nbsp;-5,&nbsp;USB_DDK_DEVICE_BUSY&nbsp;=&nbsp;-6,&nbsp;USB_DDK_TIMEOUT&nbsp;=&nbsp;-7<br>} | USB DDK error code definition.|
### Variables
| Name| Description|
| -------- | -------- |
| [bmRequestType](#bmrequesttype) | Request type.|
| [bRequest](#brequest) | Specific request.|
| [wValue](#wvalue) | Value corresponding to **wValue** in the USB protocol. Its meaning varies according to the request.|
| [wIndex](#windex) | Index corresponding to **wIndex** in the USB protocol. It is usually used to transfer the index or offset. Its meaning varies according to the request. |
| [wLength](#wlength) | Data length corresponding to **wLength** in the USB protocol. If data is transferred, this field indicates the number of transferred bytes.|
| [bLength](#blength) | Size of the descriptor, in bytes.|
| [bDescriptorType](#bdescriptortype) | Descriptor type.|
| [bcdUSB](#bcdusb) | USB protocol release number.|
| [bDeviceClass](#bdeviceclass) | Interface class code allocated by the USB-IF.|
| [bDeviceSubClass](#bdevicesubclass) | Device subclass code allocated by USB-IF. The value is limited by that of bDeviceClass.|
| [bDeviceProtocol](#bdeviceprotocol) | Protocol code allocated by USB-IF. The value is limited by that of [bDeviceClass](#bdeviceclass) and [bDeviceSubClass](#bdevicesubclass).|
| [bMaxPacketSize0](#bmaxpacketsize0) | Maximum packet size of endpoint 0. Only values 8, 16, 32, and 64 are valid.|
| [idVendor](#idvendor) | Vendor ID allocated by USB-IF.|
| [idProduct](#idproduct) | Product ID allocated by the vendor.|
| [bcdDevice](#bcddevice) | Device release number.|
| [iManufacturer](#imanufacturer) | Index of the string descriptor that describes the vendor.|
| [iProduct](#iproduct) | Index of the string descriptor that describes the product.|
| [iSerialNumber](#iserialnumber) | Index of the string descriptor that describes the device SN.|
| [bNumConfigurations](#bnumconfigurations) | Configuration quantity.|
| [wTotalLength](#wtotallength) | Total length of the configuration descriptor, including the configuration, interface, endpoint, and class- or vendor-specific descriptors.|
| [bNumInterfaces](#bnuminterfaces) | Number of interfaces supported by the configuration.|
| [bConfigurationValue](#bconfigurationvalue) | Configuration index, which is used to select the configuration.|
| [iConfiguration](#iconfiguration) | Index of the string descriptor that describes the configuration.|
| [bmAttributes](#bmattributes) | Configuration attributes, including the power mode and remote wakeup.|
| [bMaxPower](#bmaxpower) | Maximum power consumption of the bus-powered USB device, in 2 mA.|
| [bInterfaceNumber](#binterfacenumber) | Interface ID.|
| [bAlternateSetting](#balternatesetting) | Value used to select the alternate setting of the interface.|
| [bNumEndpoints](#bnumendpoints) | Number of endpoints (excluding endpoint 0) used by the interface.|
| [bInterfaceClass](#binterfaceclass) | Interface class code allocated by the USB-IF.|
| [bInterfaceSubClass](#binterfacesubclass) | Device subclass code allocated by USB-IF. The value is limited by that of [bInterfaceClass](#binterfaceclass).|
| [bInterfaceProtocol](#binterfaceprotocol) | Protocol code allocated by USB-IF. The value is limited by that of [bInterfaceClass](#binterfaceclass) and [bInterfaceSubClass](#binterfacesubclass).|
| [iInterface](#iinterface) | Index of the string descriptor that describes the interface.|
| [bEndpointAddress](#bendpointaddress) | Endpoint address, including the endpoint number and endpoint direction.|
| [bmAttributes](#bmattributes) | Endpoint attributes, including the transfer type, synchronization type, and usage type.|
| [wMaxPacketSize](#wmaxpacketsize) | Maximum packet size supported by an endpoint.|
| [bInterval](#binterval) | Interval for polling endpoints for data transfer.|
| [bRefresh](#brefresh) | Refresh rate for audio devices.|
| [bSynchAddress](#bsynchaddress) | Endpoint synchronization address for audio devices.|
| [interfaceHandle](#interfacehandle) | Interface operation handle.|
| [endpoint](#endpoint) | Endpoint address.|
| [timeout](#timeout) | Timeout duration, in milliseconds.|
## Variable Description
### bAlternateSetting
```
uint8_t bAlternateSetting
```
**Description**
Value used to select the alternate setting of the interface.
### bcdDevice
```
uint16_t bcdDevice
```
**Description**
Device release number.
### bcdUSB
```
uint16_t bcdUSB
```
**Description**
USB protocol release number.
### bConfigurationValue
```
uint8_t bConfigurationValue
```
**Description**
Configuration index, which is used to select the configuration.
### bDescriptorType
```
uint8_t bDescriptorType
```
**Description**
Descriptor type.
### bDeviceClass
```
uint8_t bDeviceClass
```
**Description**
Interface class code allocated by the USB-IF.
### bDeviceProtocol
```
uint8_t bDeviceProtocol
```
**Description**
Protocol code allocated by USB-IF. The value is limited by that of [bDeviceClass](#bdeviceclass) and [bDeviceSubClass](#bdevicesubclass).
### bDeviceSubClass
```
uint8_t bDeviceSubClass
```
**Description**
Device subclass code allocated by USB-IF. The value is limited by that of bDeviceClass.
### bEndpointAddress
```
uint8_t bEndpointAddress
```
**Description**
Endpoint address, including the endpoint number and endpoint direction.
### bmAttributes
```
uint8_t bmAttributes
```
**Description**
Endpoint attributes, including the transfer type, synchronization type, and usage type.
### bInterfaceClass
```
uint8_t bInterfaceClass
```
**Description**
Interface class code allocated by the USB-IF.
### bInterfaceNumber
```
uint8_t bInterfaceNumber
```
**Description**
Interface ID.
### bInterfaceProtocol
```
uint8_t bInterfaceProtocol
```
**Description**
Protocol code allocated by USB-IF. The value is limited by that of [bInterfaceClass](#binterfaceclass) and [bInterfaceSubClass](#binterfacesubclass).
### bInterfaceSubClass
```
uint8_t bInterfaceSubClass
```
**Description**
Device subclass code allocated by USB-IF. The value is limited by that of [bInterfaceClass](#binterfaceclass).
### bInterval
```
uint8_t bInterval
```
**Description**
Interval for polling endpoints for data transfer.
### bLength
```
uint8_t bLength
```
**Description**
Size of the descriptor, in bytes.
### bmAttributes
```
uint8_t bmAttributes
```
**Description**
Configuration attributes, including the power mode and remote wakeup.
### bMaxPacketSize0
```
uint8_t bMaxPacketSize0
```
**Description**
Maximum packet size of endpoint 0. Only values 8, 16, 32, and 64 are valid.
### bMaxPower
```
uint8_t bMaxPower
```
**Description**
Maximum power consumption of the bus-powered USB device, in 2 mA.
### bNumConfigurations
```
uint8_t bNumConfigurations
```
**Description**
Configuration quantity.
### bNumEndpoints
```
uint8_t bNumEndpoints
```
**Description**
Number of endpoints (excluding endpoint 0) used by the interface.
### bNumInterfaces
```
uint8_t bNumInterfaces
```
**Description**
Number of interfaces supported by the configuration.
### bRefresh
```
uint8_t bRefresh
```
**Description**
Refresh rate for audio devices.
### bSynchAddress
```
uint8_t bSynchAddress
```
**Description**
Endpoint synchronization address for audio devices.
### endpoint
```
uint8_t endpoint
```
**Description**
Endpoint address.
### iConfiguration
```
uint8_t iConfiguration
```
**Description**
Index of the string descriptor that describes the configuration.
### idProduct
```
uint16_t idProduct
```
**Description**
Product ID allocated by the vendor.
### idVendor
```
uint16_t idVendor
```
**Description**
Vendor ID allocated by USB-IF.
### iInterface
```
uint8_t iInterface
```
**Description**
Index of the string descriptor that describes the interface.
### iManufacturer
```
uint8_t iManufacturer
```
**Description**
Index of the string descriptor that describes the vendor.
### wIndex
```
uint16_t wIndex
```
**Description**
Index corresponding to **wIndex** in the USB protocol. It is usually used to transfer the index or offset. Its meaning varies according to the request.
### interfaceHandle
```
uint64_t interfaceHandle
```
**Description**
Interface operation handle.
### iProduct
```
uint8_t iProduct
```
**Description**
Index of the string descriptor that describes the product.
### iSerialNumber
```
uint8_t iSerialNumber
```
**Description**
Index of the string descriptor that describes the device SN.
### wLength
```
uint16_t wLength
```
**Description**
Data length corresponding to **wLength** in the USB protocol. If data is transferred, this field indicates the number of transferred bytes.
### bRequest
```
uint8_t bRequest
```
**Description**
Specific request.
### bmRequestType
```
uint8_t bmRequestType
```
**Description**
Request type.
### timeout
```
uint32_t timeout
```
**Description**
Timeout duration, in milliseconds.
### wValue
```
uint16_t wValue
```
**Description**
Value corresponding to **wValue** in the USB protocol. Its meaning varies according to the request.
### wMaxPacketSize
```
uint16_t wMaxPacketSize
```
**Description**
Maximum packet size supported by an endpoint.
### wTotalLength
```
uint16_t wTotalLength
```
**Description**
Total length of the configuration descriptor, including the configuration, interface, endpoint, and class- or vendor-specific descriptors.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册