Ethernet.setSubnetMask()

名称

Ethernet.setSubnetMask()

説明

ネットワークのサブネットマスクを設定する。DHCPのときは利用しない。

書式

void EthernetClass::setSubnetMask(const IPAddress subnet);

引数

subnetネットワークのサブネットマスク。

戻り値

なし。

使用例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#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 () {}

オリジナルのページ

https://www.arduino.cc/reference/en/libraries/ethernet/ethernet.setsubnetmask/

最終更新日

January 7, 2024

inserted by FC2 system