You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.1 KiB
61 lines
1.1 KiB
/*
|
|
|
|
Simple serial <--> network proxy demonstration.
|
|
|
|
*/
|
|
|
|
#include <libw5100.h>
|
|
|
|
void setup() {
|
|
/*
|
|
Setup function required by Arduino
|
|
*/
|
|
|
|
// Configure the network device
|
|
SpiConfiguration SPI = SpiConfiguration();
|
|
SPI.begin();
|
|
W5100Device W5100 = W5100Device(PIN_RESET);
|
|
NetworkInterface Network = NetworkInterface(W5100);
|
|
|
|
// You need to customise these to your own environment
|
|
Network.device.setIp(210,55,77,111);
|
|
Network.device.setMask(255,255,255,128);
|
|
Network.device.setGateway(210,55,77,1);
|
|
|
|
Serial.begin(9600); // Read the output in the Arduino serial monitor
|
|
|
|
while (1) {
|
|
NetworkConnection conn = Network.listen(7);
|
|
|
|
Serial.println("Waiting for client...");
|
|
|
|
while (!conn.isConnected()) {
|
|
delay(500);
|
|
}
|
|
|
|
Serial.println("Connected...");
|
|
|
|
while (conn.isConnected()) {
|
|
if (conn.available()) {
|
|
Serial.print(conn.read(), BYTE);
|
|
}
|
|
|
|
if (Serial.available()) {
|
|
conn.print(Serial.read());
|
|
}
|
|
}
|
|
|
|
conn.close();
|
|
Serial.println("Connection closed.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
void loop() {
|
|
/*
|
|
Loop function required by Arduino
|
|
*/
|
|
}
|