Ethernet.begin()

[Ethernet]

説明

Initializes the Ethernet library and network settings.

This library supports also DHCP. Using Ethernet.begin(mac) または Ethernet.begin() with the proper network setup, the Ethernet shield will automatically obtain an IP address.

Syntax

Ethernet.begin();
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: an array of 6 bytes that contains an MAC (Media access control) address. Since every 86Duino has a fixed MAC address that cannot be changed, this parameter is unused, and is reserved here just for the purpose of compatibility to Arduino’s Ethernet library.
  • ip: the device IP address that you want to set for 86Duino (array of 4 bytes)
  • dns: the IP address of the DNS server (array of 4 bytes). optional: defaults to the device IP address with the last octet set to 1
  • gateway: the IP address of the network gateway (array of 4 bytes). optional: defaults to the device IP address with the last octet set to 1
  • subnet: the subnet mask of the network (array of 4 bytes). optional: defaults to 255.255.255.0

Returns

The DHCP version of this function, Ethernet.begin(mac) または Ethernet.begin(), returns an int: 1 on a successful DHCP connection, 0 on failure. The other versions don’t return anything.

Example

#include <Ethernet.h>
 
byte mac[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };  
//the IP address:
byte ip[] = { 10, 0, 0, 177 };    
 
void setup()
{
  Ethernet.begin(mac, ip);
}
 
void loop () {}

Libraries Reference Home

86Duino のリファレンスのテキストは Arduino レファレンス を編集したもので、 Creative Commons Attribution-ShareAlike 3.0 License下でライセンスされています。リファレンス内のコードサンプルはパブリックドメインとして公開されています。

コメントする

上部へスクロール