54 lines
1.4 KiB
C++
54 lines
1.4 KiB
C++
/* Built-in */
|
|
#include <SPI.h>
|
|
|
|
/* Extra Libraries */
|
|
#include <EthernetENC.h>
|
|
|
|
/* Local includes */
|
|
#incldue config.h
|
|
|
|
// Set 10 minute compressor delay if not otherwise defined.
|
|
#ifndef COMP_DELAY
|
|
#define COMP_DELAY 600000
|
|
#endif
|
|
|
|
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
|
|
IPAddress ip(192, 168, 1, 177);
|
|
IPAddress myDns(192, 168, 1, 1);
|
|
|
|
// Initialize the Ethernet client library
|
|
// with the IP address and port of the server
|
|
// that you want to connect to (port 80 is default for HTTP):
|
|
EthernetClient client;
|
|
|
|
void setup() {
|
|
Serial.begin(9600);
|
|
while (!Serial) {
|
|
; // wait for serial port to connect. Needed for native USB port only
|
|
}
|
|
|
|
// start the Ethernet connection:
|
|
Serial.println("Initialize Ethernet with DHCP:");
|
|
if (Ethernet.begin(mac) == 0) {
|
|
Serial.println("Failed to configure Ethernet using DHCP");
|
|
// Check for Ethernet hardware present
|
|
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
|
|
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
|
|
while (true) {
|
|
delay(1); // do nothing, no point running without Ethernet hardware
|
|
}
|
|
}
|
|
if (Ethernet.linkStatus() == LinkOFF) {
|
|
Serial.println("Ethernet cable is not connected.");
|
|
}
|
|
// try to congifure using IP address instead of DHCP:
|
|
Ethernet.begin(mac, ip, myDns);
|
|
} else {
|
|
Serial.print(" DHCP assigned IP ");
|
|
Serial.println(Ethernet.localIP());
|
|
}
|
|
}
|
|
|
|
void loop() {
|
|
}
|