當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Arduino Ethernet - Ethernet.setSubnetMask()用法及代碼示例

說明

設置網絡的子網掩碼。不適用於 DHCP。

用法

Ethernet.setSubnetMask(subnet)

參數

  • subnet:網絡的子網掩碼(IPAddress)

返回

示例

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);
IPAddress myDns(192, 168, 1, 1);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 0, 0);

void setup() {
  Ethernet.begin(mac, ip, myDns, gateway, subnet);
  IPAddress newSubnet(255, 255, 255, 0);
  Ethernet.setSubnetMask(newSubnet);  // change the subnet mask
}

void loop () {}

相關用法


注:本文由純淨天空篩選整理自arduino.cc大神的英文原創作品 Ethernet - Ethernet.setSubnetMask()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。