提交 78c693d3 编写于 作者: S shawn_he

update doc

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 d37d67ba
......@@ -94,7 +94,7 @@ mdns.removeLocalService(context, localServiceInfo, function (error, data) {
1. Connect the device to the Wi-Fi network.
2. Import the **mdns** namespace from **@ohos.net.mdns**.
3. Create a **DiscoveryService** object, which is used to discover mDNS services of the specified type.
3. Creates a **DiscoveryService** object, which is used to discover mDNS services of the specified type.
4. Subscribe to mDNS service discovery status changes.
5. Enable discovery of mDNS services on the LAN.
6. Stop searching for mDNS services on the LAN.
......@@ -116,20 +116,6 @@ class EntryAbility extends UIAbility {
}
let context = globalThis.context;
// Create a LocalService object.
let localServiceInfo = {
serviceType: "_print._tcp",
serviceName: "servicename",
port: 5555,
host: {
address: "10.14.**.***",
},
serviceAttribute: [{
key: "111",
value: [1]
}]
}
// Create a DiscoveryService object, which is used to discover mDNS services of the specified type.
let serviceType = "_print._tcp";
let discoveryService = mdns.createDiscoveryService(context, serviceType);
......
......@@ -610,8 +610,10 @@ Call [Transliterator](../reference/apis/js-apis-i18n.md#transliterator9) APIs to
Call **transform** to obtain the transliterated string.
```js
let transliterator = I18n.Transliterator.getInstance("Any-Latn"); // Any-Latn means to convert any text to Latn text.
let transliterator = I18n.Transliterator.getInstance("Any-Latin"); // Any-Latin means to convert any text to Latin text.
let transformText = transliterator.transform ("Hello"); // transformText = "nǐ hǎo"
let transliterator2 = I18n.Transliterator.getInstance("Latin-ASCII"); // Latin-ASCII means to convert Latin text to ASCII text.
transformText = transliterator2.transform(transformText); // transformText = "ni hao"
```
## Obtaining the Character Type
......
# Native APIs
- [Using Native APIs in Application Projects](napi-guidelines.md)
- Graphics
- [Drawing Development](drawing-guidelines.md)
- [NativeBuffer Development](native-buffer-guidelines.md)
- [NativeImage Development](native-image-guidelines.md)
- [NativeVsync Development](native-vsync-guidelines.md)
- [Native Window Development](native-window-guidelines.md)
- Resource Management
- [Raw File Development](rawfile-guidelines.md)
- AI
- [Using MindSpore Lite for Model Inference](mindspore-lite-guidelines.md)
- [Using MindSpore Lite for Offline Model Conversion and Inference](mindspore-lite-offline-model-guidelines.md)
- [Connecting the Neural Network Runtime to an AI Inference Framework](neural-network-runtime-guidelines.md)
- Memory Development
- [Drawing Development](drawing-guidelines.md)
- [Raw File Development](rawfile-guidelines.md)
- [Native Window Development](native-window-guidelines.md)
- [Using MindSpore Lite for Model Inference](mindspore-lite-guidelines.md)
- [Using MindSpore Lite for Offline Model Conversion and Inference](mindspore-lite-offline-model-guidelines.md)
- [Connecting the Neural Network Runtime to an AI Inference Framework](neural-network-runtime-guidelines.md)
- [Purgeable Memory Development](purgeable-memory-guidelines.md)
- [USB DDK Development](usb-ddk-guidelines.md)
\ No newline at end of file
# USB DDK Development
## When to Use
USB Driver Development Kit (USB DDK) is a tool kit provided by OpenHarmony to help you develop USB device drivers for your applications based on the user mode. It provides a series of device access APIs, which implement functions such as opening and closing USB interfaces, performing non-isochronous and isochronous data transfer, and implementing control transfer and interrupt transfer over USB pipes, etc.
## Available APIs
| Name| Description|
| -------- | -------- |
| OH_Usb_Init(void) | Initializes the DDK.|
| OH_Usb_Release(void) | Releases the DDK.|
| OH_Usb_GetDeviceDescriptor(uint64_t deviceId, struct UsbDeviceDescriptor *desc) | Obtains the device descriptor.|
| OH_Usb_GetConfigDescriptor(uint64_t deviceId, uint8_t configIndex, struct UsbDdkConfigDescriptor **const config) | Obtains the configuration descriptor. To avoid memory leakage, use **OH_Usb_FreeConfigDescriptor()** to release a descriptor after use.|
| OH_Usb_FreeConfigDescriptor(const struct UsbDdkConfigDescriptor *const config) | Releases a configuration descriptor. To avoid memory leakage, release a descriptor after use.|
| OH_Usb_ClaimInterface(uint64_t deviceId, uint8_t interfaceIndex, uint64_t *interfaceHandle) | Declares a USB interface.|
| OH_Usb_ReleaseInterface(uint64_t interfaceHandle) | Releases a USB interface.|
| OH_Usb_SendPipeRequest(const struct UsbRequestPipe *pipe, UsbDeviceMemMap *devMmap) | Sends a pipe request. This API works in a synchronous manner. It applies to interrupt transfer and bulk transfer.|
| OH_Usb_CreateDeviceMemMap(uint64_t deviceId, size_t size, UsbDeviceMemMap **devMmap) | Creates a buffer. To avoid memory leakage, use **OH_Usb_DestroyDeviceMemMap()** to destroy a buffer after use.|
| OH_Usb_DestroyDeviceMemMap(UsbDeviceMemMap *devMmap) | Destroys a buffer. To avoid resource leakage, destroy a buffer in time after use.|
For details about the APIs, see [USB DDK](../reference/native-apis/_usb_ddk.md).
## How to Develop
To develop a USB driver using the USB DDK in OpenHarmony, perform the following steps:
1. Obtain the device descriptor. Initialize the DDK by calling **OH_Usb_Init** of **usb_ddk_api.h**, and obtain the device descriptor by calling **OH_Usb_GetDeviceDescriptor**.
```c++
// Initialize the USB DDK.
OH_Usb_Init();
struct UsbDeviceDescriptor devDesc;
uint64_t deviceId = 0;
// Obtain the device descriptor.
OH_Usb_GetDeviceDescriptor(deviceId, &devDesc);
```
2. Obtain the configuration descriptor, and declare the USB interface. Obtain the configuration descriptor **config** by calling **OH_Usb_GetConfigDescriptor** of **usb_ddk_api.h**, and declare the USB interface by calling **OH_Usb_ClaimInterface**.
```c++
struct UsbDdkConfigDescriptor *config = nullptr;
// Obtain the configuration descriptor.
OH_Usb_GetConfigDescriptor(deviceId, 1, &config);
// Obtain the index of the target USB interface based on the configuration descriptor.
uint8_t interfaceIndex = 0;
// Declare the USB interface.
uint64_t interfaceHandle = 0;
OH_Usb_ClaimInterface(deviceId, interfaceIndex, &interfaceHandle);
// Release the configuration descriptor.
OH_Usb_FreeConfigDescriptor(config);
```
3. Create a device memory map, and send a request. Create the device memory map **devMmap** by calling **OH_Usb_CreateDeviceMemMap** of **usb_ddk_api.h**, and send a request by calling **OH_Usb_SendPipeRequest**.
```c++
struct UsbDeviceMemMap *devMmap = nullptr;
// Create a buffer for storing data.
size_t bufferLen = 10;
OH_Usb_CreateDeviceMemMap(deviceId, bufferLen, &devMmap);
struct UsbRequestPipe pipe;
pipe.interfaceHandle = interfaceHandle;
// Obtain the target endpoint based on the configuration descriptor.
pipe.endpoint = 128;
pipe.timeout = UINT32_MAX;
// Send a request.
OH_Usb_SendPipeRequest(&pipe, devMmap);
```
4. Release resources. After all requests are processed and before the application exits, destroy the buffer by calling **OH_Usb_DestroyDeviceMemMap** of **usb_ddk_api.h** to release resources. Release the USB interface by calling **OH_Usb_ReleaseInterface**. Release the USB DDK by calling **OH_Usb_Release**.
```c++
// Destroy the buffer.
OH_Usb_DestroyDeviceMemMap(devMmap);
// Release the USB interface.
OH_Usb_ReleaseInterface(interfaceHandle);
// Release the USB DDK.
OH_Usb_Release();
```
......@@ -221,7 +221,7 @@
- Resource Management
- [@ohos.i18n (Internationalization)](js-apis-i18n.md)
- [@ohos.intl (Internationalization)](js-apis-intl.md)
- [@ohos.resourceManager (Resource Manager)](js-apis-resource-manager.md)
- [@ohos.resourceManager (Resource Management)](js-apis-resource-manager.md)
- Background Task
- [@ohos.distributedMissionManager (Distributed Mission Management)](js-apis-distributedMissionManager.md)
......@@ -291,6 +291,7 @@
- [@ohos.net.mdns (mDNS Management)](js-apis-net-mdns.md)
- [@ohos.net.sharing (Network Sharing)](js-apis-net-sharing.md)
- [@ohos.net.socket (Socket Connection)](js-apis-socket.md)
- [@ohos.net.statistics (Traffic Management)](js-apis-net-statistics.md)
- [@ohos.net.webSocket (WebSocket Connection)](js-apis-webSocket.md)
- [@ohos.request (Upload and Download)](js-apis-request.md)
......
......@@ -1750,6 +1750,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**Example**
......@@ -1795,6 +1796,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**Example**
......
# # @ohos.net.ethernet (Ethernet Connection Management)
The **ethernet** module provides wired network capabilities, which allow users to set the IP address, subnet mask, gateway, and Domain Name System (DNS) server of a wired network.
The **ethernet** module provides wired network capabilities, which allow users to set the IP address, subnet mask, gateway, and Domain Name System (DNS) server, and HTTP proxy of a wired network.
> **NOTE**
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......@@ -55,7 +55,12 @@ ethernet.setIfaceConfig("eth0", {
route: "192.168.xx.xxx",
gateway: "192.168.xx.xxx",
netMask: "255.255.255.0",
dnsServers: "1.1.1.1"
dnsServers: "1.1.1.1",
httpProxy: {
host: "180.89.xx.xx",
port: 8080,
exclusionList: {"example.com","192.168.0.1"}
}
}, (error) => {
if (error) {
console.log("setIfaceConfig callback error = " + JSON.stringify(error));
......@@ -114,7 +119,12 @@ ethernet.setIfaceConfig("eth0", {
route: "192.168.xx.xxx",
gateway: "192.168.xx.xxx",
netMask: "255.255.255.0",
dnsServers: "1.1.1.1"
dnsServers: "1.1.1.1",
httpProxy: {
host: "180.89.xx.xx",
port: 8080,
exclusionList: {"example.com","192.168.0.1"}
}
}).then(() => {
console.log("setIfaceConfig promise ok ");
}).catch(error => {
......@@ -476,6 +486,7 @@ Defines the network configuration for the Ethernet connection.
| gateway | string | Yes| Gateway of the Ethernet connection. The value must be an IPv4 address, which is a 32-bit number displayed in dotted decimal notation and each 8-bit field ranges from 0 to 255. This parameter does not need to be configured in DHCP mode.|
| netMask | string | Yes| Subnet mask of the Ethernet connection. The value must be an IPv4 address, which is a 32-bit number displayed in dotted decimal notation and each 8-bit field ranges from 0 to 255. This parameter does not need to be configured in DHCP mode.|
| dnsServers | string | Yes| DNS server addresses of the Ethernet connection. The value must be an IPv4 address. This parameter does not need to be configured in DHCP mode. Multiple addresses are separated by commas (,).|
| httpProxy<sup>10+</sup> | [HttpProxy](js-apis-net-connection.md#httpproxy) | No| HTTP proxy of the Ethernet connection. By default, no proxy is configured.|
## IPSetMode<sup>9+</sup>
......
......@@ -1870,7 +1870,7 @@ radio.getNrOptionMode((err, data) => {
getNrOptionMode\(slotId: number, callback: AsyncCallback\<NrOptionMode\>\): void
Obtains the NR option mode. This API uses an asynchronous callback to return the result.
Obtains the NR option mode for the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
> **NOTE**
>
......@@ -3228,17 +3228,15 @@ Enumerates preferred network modes.
Defines the cell information.
**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Mandatory| Description |
| ----------------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| networkType | [NetworkType](#networktype) | Yes | Network type of the cell. |
| isCamped | boolean | Yes | Cell status. |
| timeStamp | number | Yes | Timestamp when cell information is obtained. |
| isCamped | boolean | Yes | Cell status.<br>**System API**: This is a system API. |
| timeStamp | number | Yes | Timestamp when cell information is obtained.<br>**System API**: This is a system API. |
| signalInformation | [SignalInformation](#signalinformation) | Yes | Signal information. |
| data | [CdmaCellInformation](#cdmacellinformation8) \| [GsmCellInformation](#gsmcellinformation8) \| [LteCellInformation](#ltecellinformation8) \| [NrCellInformation](#nrcellinformation8) \| [TdscdmaCellInformation](#tdscdmacellinformation8) | Yes | CDMA cell information\|GSM cell information\|LTE cell information\|NR cell information\|TD-SCDMA cell information|
| data | [CdmaCellInformation](#cdmacellinformation8) \| [GsmCellInformation](#gsmcellinformation8) \| [LteCellInformation](#ltecellinformation8) \| [NrCellInformation](#nrcellinformation8) \| [TdscdmaCellInformation](#tdscdmacellinformation8) | Yes | CDMA cell information\|GSM cell information\|LTE cell information\|NR cell information\|TD-SCDMA cell information<br>**System API**: This is a system API.|
## CdmaCellInformation<sup>8+</sup>
......
# @ohos.resourceManager (Resource Manager)
# @ohos.resourceManager (Resource Management)
The **resourceManager** module provides APIs to obtain information about application resources based on the current configuration, including the language, region, screen direction, MCC/MNC, as well as device capability and density.
......@@ -3506,7 +3506,7 @@ For details about the error codes, see [Resource Manager Error Codes](../errorco
### getColorByName<sup>10+</sup>
getStringByName(resName: string): Promise&lt;number&gt;
getColorByName(resName: string): Promise&lt;number&gt;
Obtains the color value corresponding to the specified resource name. This API uses a promise to return the result.
......
......@@ -56,6 +56,7 @@
- [Ethernet Connection Error Codes](errorcode-net-ethernet.md)
- [Network Sharing Error Codes](errorcode-net-sharing.md)
- [mDNS Error Codes](errorcode-net-mdns.md)
- [Traffic Management Error Codes](errorcode-net-statistics.md)
- Connectivity
- [Bluetooth Error Codes](errorcode-bluetoothManager.md)
- [Wi-Fi Error Codes](errorcode-wifi.md)
......
# Traffic Management Error Codes
> **NOTE**
>
> This topic describes only module-specific error codes. For details about universal error codes, see [Universal Error Codes](errorcode-universal.md).
## 2100001 Invalid Parameters
**Error Information**
Invalid parameter value.
**Description**
This error code is reported if any input parameter value is incorrect.
**Possible Causes**
The end time is earlier than the start time.
**Solution**
Check whether the start time and end time are properly set.
## 2100002 Service Connection Failure
**Error Information**
Operation failed. Cannot connect to service.
**Description**
This error code is reported if a service connection failure occurs.
**Possible Causes**
The service is abnormal.
**Solution**
Check whether system services are running properly.
## 2100003 System Internal Error
**Error Information**
System internal error.
**Description**
This error code is reported if an internal system error occurs.
**Possible Causes**
1. The memory is abnormal.
2. A null pointer is present.
**Solution**
1. Check whether the memory space is sufficient. If not, clear the memory and try again.
2. Check whether the system is normal. If not, try again later or restart the device.
## 2103005 Failed to Read the System Map
**Error Information**
Failed to read map.
**Description**
This error code is reported if the attempt to read the system map fails.
**Possible Causes**
The attempt to read traffic data on the kernel map object fails.
**Solution**
Check whether traffic is generated for the specified NIC or application.
## 2103011 Failed to Create a System Map
**Error Information**
Failed to create map.
**Description**
This error code is reported if the attempt to create a kernel map object fails.
**Possible Causes**
No traffic is generated on the NIC and therefore a kernel traffic object has not been created.
**Solution**
Ensure that traffic is generated on the NIC.
## 2103012 Failed to Obtain the NIC Name
**Error Information**
Get iface name failed.
**Description**
This error code is reported if the attempt to obtain the NIC name fails.
**Possible Causes**
The NIC name does not exist on the local host.
**Solution**
Check whether the input NIC name is correct.
## 2103017 Failed to Read the Database
**Error Information**
Read data from database failed.
**Description**
This error code is reported if the attempt to read the database fails.
**Possible Causes**
The database is damaged.
**Solution**
Check whether the database file on the local host is damaged.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册