Ethernet

This is a library for Ethernet initialization. GR-ROSE SDK establishes a network with FreeRTOS + TCP. Switching between fixed IP and DHCP cannot be done dynamically as with Arduino's Ethernet library. Basically, when performing XRCE-DDS communication for ROS2, it uses with fixed IP, when performing Internet communication such as AWS IoT connection, it assumes that IP is acquired by DHCP, and this switching is a macro of compiler option it does in "USING_UXR". The default SDK specifies USING_UXR and is set to use XRCE-DDS with fixed IP. This library carries out the establishment of the network with fixed IP. Specify #include <Ethernet.h> for use.

Note that if you do not specify USING_UXR, the network probability by DHCP will be performed before executing setup.

begin

Description
Initializes the Ethernet library and network settings. The DHCP automatically obtains an IP address, DNS, default gateway, and subnet mask.
Syntax
int Ethernet.begin(mac)
Ethernet.begin(mac, ip)
Ethernet.begin(mac, ip, dns)
Ethernet.begin(mac, ip, dns, gateway)
Ethernet.begin(mac, ip, dns, gateway, subnet)
Parameters
mac: MAC address (array of 6 bytes)
ip: IP address (array of 4 bytes)
dns: Name server address (array of 4 bytes) - If not specified, 143.103.47.193 is set.
gateway: Default gateway address (array of 4 bytes) - If not specified, 172.27.49.1 is set.
subnet: Subnet mask (array of 4 bytes) - If not specified, 255.255.255.0 is set.
Returns
None

localIP

Description
Obtains the IP address of the board.
Syntax
IPAddress Ethernet.localIP()
Parameters
None
Returns
The IP address

Sample Program

Refer to the sample program for ROS2.