[W5500-EVB-Pico]
#include <SPI.h>
#include <Ethernet2.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network.
// gateway and subnet are optional:
byte mac = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 100, 22);
IPAddress gateway(192, 168, 100, 1);
IPAddress subnet(255, 255, 255, 0);
// telnet defaults to port 23
EthernetServer server(23);
boolean alreadyConnected = false; // whether or not the client was connected previously
void setup() {
//Ethernet.init(1); //SPI0 CS Pin (GP1)
// initialize the ethernet device
Ethernet.begin(mac, ip, gateway, subnet);
// start listening for clients
server.begin();
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.print(“Chat server address:”);
Serial.println(Ethernet.localIP());
}
void loop() {
// wait for a new client:
EthernetClient client = server.available();
// when the client sends the first byte, say hello:
if (client) {
if (!alreadyConnected) {
// clead out the input buffer:
client.flush();
Serial.println(“We have a new client”);
client.println(“Hello, client!”);
alreadyConnected = true;
}
if (client.available() > 0) {
// read the bytes incoming from the client:
char thisChar = client.read();
// echo the bytes back to the client:
server.write(thisChar);
// echo the bytes to the server as well:
Serial.write(thisChar);
}
}
}
출처
https://blog.naver.com/yusanghyun26/222527712230
아래와 같은 메시지가 시리얼로 표시가 됩니다.
“Chat server address:(IP unset)” 라는 시리얼로 나옵니다.
제 pc ipconfig 는 아래와 같습니다.
이더넷 어댑터 이더넷:
연결별 DNS 접미사. . . . :
링크-로컬 IPv6 주소 . . . . : fe80::eb8ㅌㅌㅌㅌ:c7e1:dd8b%9
IPv4 주소 . . . . . . . . . : 192.168.100.6
서브넷 마스크 . . . . . . . : 255.255.255.0
기본 게이트웨이 . . . . . . : 192.168.100.1
W5500-EVB-Pico 에서 동작하는 chatserver.ino 소스가 있었으면 합니다.