当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Arduino Ethernet - Ethernet.setGatewayIP()用法及代码示例


说明

设置网络网关的 IP 地址。不适用于 DHCP。

用法

Ethernet.setGatewayIP(gateway)

参数

  • gateway:网络网关的IP地址(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);

void setup() {
  Ethernet.begin(mac, ip, myDns, gateway);
  IPAddress newGateway(192, 168, 100, 1);
  Ethernet.setGatewayIP(newGateway);  // change the gateway IP address
}

void loop () {}

相关用法


注:本文由纯净天空筛选整理自arduino.cc大神的英文原创作品 Ethernet - Ethernet.setGatewayIP()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。