Skip to content

Commit 6b8e8f1

Browse files
author
Amanda Butler
authored
Update EthInterface.md
Make changes from PR #472 to live site after reviewing on test site.
1 parent 86b893c commit 6b8e8f1

File tree

1 file changed

+43
-8
lines changed

1 file changed

+43
-8
lines changed

docs/reference/api/connectivity/networksocket/EthInterface.md

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,53 @@
44

55
The EthInterface provides a C++ API for connecting to the internet over Ethernet.
66

7-
### EthInterface class reference
8-
9-
[![View code](https://www.mbed.com/embed/?type=library)](https://os.mbed.com/docs/v5.8/mbed-os-api-doxy/class_eth_interface.html)
7+
By default, this class does not require any configuration. It is able to pick up the default Ethernet driver for the target and select correct network stack.
108

119
### Usage
1210

13-
To bring up the network interface:
11+
To statically initialize the driver, create an object without passing any parameters:
12+
13+
```cpp
14+
EthernetInterface eth;
15+
```
16+
17+
Then, if the default configuration is enough, bring up the interface:
18+
19+
```cpp
20+
nsapi_error_t status = eth.connect();
21+
```
22+
23+
Now, the interface is ready to be used for [network sockets](/docs/development/reference/network-socket.html).
24+
25+
```cpp
26+
// Open a TCP socket
27+
TCPSocket socket;
28+
socket.open(&eth);
29+
30+
// Open a UDP socket
31+
UDPSocket socket;
32+
socket.open(&eth);
33+
```
34+
35+
### Configuration
1436

15-
1. Instantiate the `EthInterface` class.
16-
1. Call the `connect` function.
17-
1. Once you connect the EthInterface, you can use it as a
18-
target for opening [network sockets](/docs/v5.8/reference/network-socket.html).
37+
For EthernetInterface, there are two possible configurations:
38+
39+
- Use DHCP for network addressing. This is the default.
40+
- Use statically configured IP addresses.
41+
42+
Refer to the API below for how to set the IP addresses by calling the `set_network()` function.
43+
44+
### Troubleshooting information
45+
46+
Network interface `connect` failure causes:
47+
48+
- `NSAPI_ERROR_NO_CONNECTION` indicates that the Ethernet link up has failed. Check that the Ethernet connection is working.
49+
- `NSAPI_ERROR_DHCP_FAILURE` indicates that acquiring the IP address has failed. Check that the IP address configuration service is working.
50+
51+
### EthInterface class reference
52+
53+
[![View code](https://www.mbed.com/embed/?type=library)](https://os.mbed.com/docs/v5.8/mbed-os-api-doxy/class_eth_interface.html)
1954

2055
### EthInterface examples
2156

0 commit comments

Comments
 (0)