Skip to content

Expand Ethernet interface intro #481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 35 additions & 9 deletions docs/reference/api/connectivity/networksocket/EthInterface.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,45 @@
## Ethernet

The EthInterface provides a C++ API for connecting to the internet over Ethernet.
The `EthInterface` provides a C++ API for connecting to the internet over Ethernet. By default, this class does not require any configuration. It is able to pick up the default Ethernet driver for the target and select the correct network stack.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anything else developers should know about what this API is and what it does? This section seems short.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its hard to see what should be inserted here.

Networking architecture in general is described in #470 and Ethernet MAC drivers will be explained on their own page (to be moved to Handbook later on).

This whole API usage is concised in the 2 line example below in the Usage section.

EthernetInterface eth;
eth.connect();


### EthInterface class reference
### Usage

[![View code](https://www.mbed.com/embed/?type=library)](http://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/class_eth_interface.html)
To statically initialize the driver, create an object without passing any parameters:

### Usage
```cpp
EthernetInterface eth;
```

Then, if the default configuration is enough, bring up the interface:

```cpp
nsapi_error_t status = eth.connect();
```

Now, the interface is ready to be used for [network sockets](/docs/development/reference/network-socket.html).

```cpp
// Open a TCP socket
TCPSocket socket;
socket.open(&eth);

To bring up the network interface:
// Open a UDP socket
UDPSocket socket;
socket.open(&eth);
```

1. Instantiate the `EthInterface` class.
1. Call the `connect` function.
1. Once you connect the EthInterface, you can use it as a
target for opening [network sockets](/docs/development/reference/network-socket.html).
### Configuration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should move the content from this section into the connectivity configuration section.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see that it fits there.
That configuration section is about build time configuration.

This however, refers to the network configuration, how to get the IP address. It is just that you either call the set_network() or not... There is nothing to configure through JSON settings.

Should I change the tittle?
Maybe IP address configuration would be better to reflect this.


For EthernetInterface, there are two possible configurations:

- Use DHCP for network addressing. This is the default.
- Use statically configured IP addresses.

Refer to the API below for how to set the IP addresses by calling the `set_network()` function.

### EthInterface class reference

[![View code](https://www.mbed.com/embed/?type=library)](http://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/class_eth_interface.html)

### EthInterface examples

Expand Down