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.
- Initializes the Ethernet library and network settings. The DHCP automatically obtains an IP address, DNS, default gateway, and subnet mask.
Ethernet.begin(mac, ip, dns)
Ethernet.begin(mac, ip, dns, gateway)
Ethernet.begin(mac, ip, dns, gateway, subnet)
- 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, 220.127.116.11 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.
- Obtains the IP address of the board.
- IPAddress Ethernet.localIP()
- The IP address
Refer to the sample program for ROS2.