Ethernet.begin()

[Ethernet]

描述

Initializes the Ethernet library and network settings.

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

語法

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);

參數

  • 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

回傳

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

範例

#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 () {}

函式庫參考主頁面

86Duino 參考的文本是根據 Creative Commons Attribution-ShareAlike 3.0 License,部分文本是從 the Arduino reference 修改的。 參考中的代碼示例已發佈到公共領域。

發表評論

上部へスクロール