-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add examples to ensure drivers built in CI
- Loading branch information
1 parent
612c755
commit 160c011
Showing
3 changed files
with
270 additions
and
0 deletions.
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
libraries/lwIP_enc28j60/examples/WiFiClient-ENC28J60/WiFiClient-ENC28J60.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
This sketch establishes a TCP connection to a "quote of the day" service. | ||
It sends a "hello" message, and then prints received data. | ||
*/ | ||
|
||
#include <ENC28J60lwIP.h> | ||
|
||
const char* host = "djxmmx.net"; | ||
const uint16_t port = 17; | ||
|
||
ENC28J60lwIP eth(1 /* chip select */); | ||
|
||
void setup() { | ||
// Set up SPI pinout to match your HW | ||
SPI.setRX(0); | ||
SPI.setCS(1); | ||
SPI.setSCK(2); | ||
SPI.setTX(3); | ||
|
||
Serial.begin(115200); | ||
delay(5000); | ||
Serial.println(); | ||
Serial.println(); | ||
Serial.println("Starting Ethernet port"); | ||
|
||
// Start the Ethernet port | ||
if (!eth.begin()) { | ||
Serial.println("No wired Ethernet hardware detected. Check pinouts, wiring."); | ||
while (1) { | ||
delay(1000); | ||
} | ||
} | ||
|
||
Serial.println(""); | ||
Serial.println("Ethernet connected"); | ||
Serial.println("IP address: "); | ||
Serial.println(eth.localIP()); | ||
} | ||
|
||
void loop() { | ||
static bool wait = false; | ||
|
||
Serial.print("connecting to "); | ||
Serial.print(host); | ||
Serial.print(':'); | ||
Serial.println(port); | ||
|
||
// Use WiFiClient class to create TCP connections | ||
WiFiClient client; | ||
if (!client.connect(host, port)) { | ||
Serial.println("connection failed"); | ||
delay(5000); | ||
return; | ||
} | ||
|
||
// This will send a string to the server | ||
Serial.println("sending data to server"); | ||
if (client.connected()) { | ||
client.println("hello from ESP8266"); | ||
} | ||
|
||
// wait for data to be available | ||
unsigned long timeout = millis(); | ||
while (client.available() == 0) { | ||
if (millis() - timeout > 5000) { | ||
Serial.println(">>> Client Timeout !"); | ||
client.stop(); | ||
delay(60000); | ||
return; | ||
} | ||
} | ||
|
||
// Read all the lines of the reply from server and print them to Serial | ||
Serial.println("receiving from remote server"); | ||
// not testing 'client.connected()' since we do not need to send data here | ||
while (client.available()) { | ||
char ch = static_cast<char>(client.read()); | ||
Serial.print(ch); | ||
} | ||
|
||
// Close the connection | ||
Serial.println(); | ||
Serial.println("closing connection"); | ||
client.stop(); | ||
|
||
if (wait) { | ||
delay(300000); // execute once every 5 minutes, don't flood remote service | ||
} | ||
wait = true; | ||
} |
90 changes: 90 additions & 0 deletions
90
libraries/lwIP_w5100/examples/WiFiClient-W5100/WiFiClient-W5100.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
This sketch establishes a TCP connection to a "quote of the day" service. | ||
It sends a "hello" message, and then prints received data. | ||
*/ | ||
|
||
#include <W5100lwIP.h> | ||
|
||
const char* host = "djxmmx.net"; | ||
const uint16_t port = 17; | ||
|
||
W5510lwIP eth(1 /* chip select */); | ||
|
||
void setup() { | ||
// Set up SPI pinout to match your HW | ||
SPI.setRX(0); | ||
SPI.setCS(1); | ||
SPI.setSCK(2); | ||
SPI.setTX(3); | ||
|
||
Serial.begin(115200); | ||
delay(5000); | ||
Serial.println(); | ||
Serial.println(); | ||
Serial.println("Starting Ethernet port"); | ||
|
||
// Start the Ethernet port | ||
if (!eth.begin()) { | ||
Serial.println("No wired Ethernet hardware detected. Check pinouts, wiring."); | ||
while (1) { | ||
delay(1000); | ||
} | ||
} | ||
|
||
Serial.println(""); | ||
Serial.println("Ethernet connected"); | ||
Serial.println("IP address: "); | ||
Serial.println(eth.localIP()); | ||
} | ||
|
||
void loop() { | ||
static bool wait = false; | ||
|
||
Serial.print("connecting to "); | ||
Serial.print(host); | ||
Serial.print(':'); | ||
Serial.println(port); | ||
|
||
// Use WiFiClient class to create TCP connections | ||
WiFiClient client; | ||
if (!client.connect(host, port)) { | ||
Serial.println("connection failed"); | ||
delay(5000); | ||
return; | ||
} | ||
|
||
// This will send a string to the server | ||
Serial.println("sending data to server"); | ||
if (client.connected()) { | ||
client.println("hello from ESP8266"); | ||
} | ||
|
||
// wait for data to be available | ||
unsigned long timeout = millis(); | ||
while (client.available() == 0) { | ||
if (millis() - timeout > 5000) { | ||
Serial.println(">>> Client Timeout !"); | ||
client.stop(); | ||
delay(60000); | ||
return; | ||
} | ||
} | ||
|
||
// Read all the lines of the reply from server and print them to Serial | ||
Serial.println("receiving from remote server"); | ||
// not testing 'client.connected()' since we do not need to send data here | ||
while (client.available()) { | ||
char ch = static_cast<char>(client.read()); | ||
Serial.print(ch); | ||
} | ||
|
||
// Close the connection | ||
Serial.println(); | ||
Serial.println("closing connection"); | ||
client.stop(); | ||
|
||
if (wait) { | ||
delay(300000); // execute once every 5 minutes, don't flood remote service | ||
} | ||
wait = true; | ||
} |
90 changes: 90 additions & 0 deletions
90
libraries/lwIP_w5500/examples/WiFiClient-W5500/WiFiClient-W5500.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
This sketch establishes a TCP connection to a "quote of the day" service. | ||
It sends a "hello" message, and then prints received data. | ||
*/ | ||
|
||
#include <W5500lwIP.h> | ||
|
||
const char* host = "djxmmx.net"; | ||
const uint16_t port = 17; | ||
|
||
W5500lwIP eth(1 /* chip select */); | ||
|
||
void setup() { | ||
// Set up SPI pinout to match your HW | ||
SPI.setRX(0); | ||
SPI.setCS(1); | ||
SPI.setSCK(2); | ||
SPI.setTX(3); | ||
|
||
Serial.begin(115200); | ||
delay(5000); | ||
Serial.println(); | ||
Serial.println(); | ||
Serial.println("Starting Ethernet port"); | ||
|
||
// Start the Ethernet port | ||
if (!eth.begin()) { | ||
Serial.println("No wired Ethernet hardware detected. Check pinouts, wiring."); | ||
while (1) { | ||
delay(1000); | ||
} | ||
} | ||
|
||
Serial.println(""); | ||
Serial.println("Ethernet connected"); | ||
Serial.println("IP address: "); | ||
Serial.println(eth.localIP()); | ||
} | ||
|
||
void loop() { | ||
static bool wait = false; | ||
|
||
Serial.print("connecting to "); | ||
Serial.print(host); | ||
Serial.print(':'); | ||
Serial.println(port); | ||
|
||
// Use WiFiClient class to create TCP connections | ||
WiFiClient client; | ||
if (!client.connect(host, port)) { | ||
Serial.println("connection failed"); | ||
delay(5000); | ||
return; | ||
} | ||
|
||
// This will send a string to the server | ||
Serial.println("sending data to server"); | ||
if (client.connected()) { | ||
client.println("hello from ESP8266"); | ||
} | ||
|
||
// wait for data to be available | ||
unsigned long timeout = millis(); | ||
while (client.available() == 0) { | ||
if (millis() - timeout > 5000) { | ||
Serial.println(">>> Client Timeout !"); | ||
client.stop(); | ||
delay(60000); | ||
return; | ||
} | ||
} | ||
|
||
// Read all the lines of the reply from server and print them to Serial | ||
Serial.println("receiving from remote server"); | ||
// not testing 'client.connected()' since we do not need to send data here | ||
while (client.available()) { | ||
char ch = static_cast<char>(client.read()); | ||
Serial.print(ch); | ||
} | ||
|
||
// Close the connection | ||
Serial.println(); | ||
Serial.println("closing connection"); | ||
client.stop(); | ||
|
||
if (wait) { | ||
delay(300000); // execute once every 5 minutes, don't flood remote service | ||
} | ||
wait = true; | ||
} |