harmony 鸿蒙# @ohos.net.ethernet (Ethernet Connection Management)
# @ohos.net.ethernet (Ethernet Connection Management)
The ethernet module provides Ethernet management functions such as obtaining the network IP address.
NOTE The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Modules to Import
import { ethernet } from '@kit.NetworkKit';
HttpProxy
type HttpProxy = connection.HttpProxy;
Defines the network proxy configuration.
System capability: SystemCapability.Communication.NetManager.Ethernet
Type | Description |
---|---|
connection.HttpProxy | Network proxy configuration. |
ethernet.getMacAddress14+
getMacAddress(): Promise<Array<MacAddressInfo>>
Obtains the names and MAC addresses of all Ethernet NICs. This API uses a promise to return the result.
Required permission: ohos.permission.GET_ETHERNET_LOCAL_MAC
System capability: SystemCapability.Communication.NetManager.Ethernet
Return value
Type | Description |
---|---|
Promise<Array<MacAddressInfo>> | Promise used to return the result. |
Error codes
ID | Error Message |
---|---|
201 | Permission denied. |
2200002 | Operation failed. Cannot connect to service. |
2201005 | Device information does not exist. |
Example
import { ethernet } from '@kit.NetworkKit';
import { BusinessError } from '@kit.BasicServicesKit';
ethernet.getMacAddress().then((data: Array<ethernet.MacAddressInfo>) => {
console.info("getMacAddress promise data = " + JSON.stringify(data));
}).catch((error: BusinessError) => {
console.error("getMacAddress promise error = " + JSON.stringify(error));
});
MacAddressInfo14+
Defines the name and MAC address of an Ethernet NIC.
System capability: SystemCapability.Communication.NetManager.Ethernet
Name | Type | Mandatory | Description |
---|---|---|---|
iface | string | Yes | Name of the Ethernet NIC. |
macAddress | string | Yes | MAC address of the Ethernet NIC. |
你可能感兴趣的鸿蒙文章
harmony 鸿蒙NetConn_ConnectionProperties
harmony 鸿蒙NetConn_NetCapabilities
harmony 鸿蒙NetConn_NetConnCallback
harmony 鸿蒙NetConn_NetHandleList
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦