Skip to content

Commit 4c7d80e

Browse files
authored
Merge pull request #1 from fprwi6labs/add_src
STM32Ethernet source files
2 parents 82979e5 + 2cbafb0 commit 4c7d80e

32 files changed

+4401
-1
lines changed

AUTHORS

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
Alberto Panu https://github.com/bigjohnson
3+
Alasdair Allan https://github.com/aallan
4+
Alice Pintus https://github.com/00alis
5+
Adrian McEwen https://github.com/amcewen
6+
Arduino LLC http://arduino.cc/
7+
Arnie97 https://github.com/Arnie97
8+
Arturo Guadalupi https://github.com/agdl
9+
Bjoern Hartmann https://people.eecs.berkeley.edu/~bjoern/
10+
chaveiro https://github.com/chaveiro
11+
Cristian Maglie https://github.com/cmaglie
12+
David A. Mellis https://github.com/damellis
13+
Dino Tinitigan https://github.com/bigdinotech
14+
Eddy https://github.com/eddyst
15+
Federico Vanzati https://github.com/Fede85
16+
Federico Fissore https://github.com/ffissore
17+
Jack Christensen https://github.com/JChristensen
18+
Johann Richard https://github.com/johannrichard
19+
Jordan Terrell https://github.com/iSynaptic
20+
Justin Paulin https://github.com/interwho
21+
lathoub https://github.com/lathoub
22+
Martino Facchin https://github.com/facchinm
23+
Matthias Hertel https://github.com/mathertel
24+
Matthijs Kooijman https://github.com/matthijskooijman
25+
Matt Robinson https://github.com/ribbons
26+
MCQN Ltd. http://mcqn.com/
27+
Michael Amie https://github.com/michaelamie
28+
Michael Margolis https://github.com/michaelmargolis
29+
Norbert Truchsess https://github.com/ntruchsess
30+
Paul Stoffregen https://github.com/PaulStoffregen
31+
per1234 https://github.com/per1234
32+
Richard Sim
33+
Scott Fitzgerald https://github.com/shfitz
34+
STMicroelectronics https://github.com/stm32duino
35+
Thibaut Viard https://github.com/aethaniel
36+
Tom Igoe https://github.com/tigoe
37+
Wi6Labs http://www.wi6labs.com/
38+
WizNet http://www.wiznet.co.kr
39+
Zach Eveland https://github.com/zeveland
40+

README

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
== License ==
2+
3+
Copyright (c) 2010 Arduino LLC. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

README.md

+29-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,29 @@
1-
# STM32Ethernet
1+
# STM32Ethernet
2+
3+
## Ethernet Library for Arduino
4+
5+
With an STM32 board with Ethernet compatibility, this library allows a STM32
6+
board (NUCLEO, DISCOVERY, ...) to connect to the internet.
7+
8+
For more information about this library please visit us at
9+
http://www.arduino.cc/en/Reference/Ethernet
10+
11+
## Note
12+
13+
The library is based on LwIP, a Lightweight TCP/IP stack.
14+
http://git.savannah.gnu.org/cgit/lwip.git
15+
The LwIP has been ported as Arduino library. The STM32Ethernet library depends
16+
on it.
17+
18+
EthernetClass::maintain() in no more required to renew IP address from DHCP.
19+
It is done automatically by the LwIP stack in a background task.
20+
21+
An Idle task is required by the LwIP stack to handle timer and data reception.
22+
This idle task is called inside the main loop in background by the function
23+
stm32_eth_scheduler(). Be careful to not lock the system inside the function
24+
loop() where LwIP could never be updated. Call EthernetUDP::parsePacket() or
25+
EthernetClient::available() performs an update of the LwIP stack.
26+
27+
## Wiki
28+
29+
You can find information at https://github.com/stm32duino/wiki/wiki/STM32Ethernet
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*
2+
Advanced Chat Server
3+
4+
A more advanced server that distributes any incoming messages
5+
to all connected clients but the client the message comes from.
6+
To use, telnet to your device's IP address and type.
7+
You can see the client's input in the serial monitor as well.
8+
9+
Circuit:
10+
* STM32 board with Ethernet support
11+
12+
created 18 Dec 2009
13+
by David A. Mellis
14+
modified 9 Apr 2012
15+
by Tom Igoe
16+
redesigned to make use of operator== 25 Nov 2013
17+
by Norbert Truchsess
18+
modified 23 Jun 2017
19+
by Wi6Labs
20+
21+
*/
22+
23+
#include <LwIP.h>
24+
#include <STM32Ethernet.h>
25+
26+
// Enter a MAC address and IP address for your controller below.
27+
// The IP address will be dependent on your local network.
28+
// gateway and subnet are optional:
29+
byte mac[] = {
30+
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
31+
};
32+
IPAddress ip(192, 168, 1, 177);
33+
IPAddress myDns(192, 168, 1, 1);
34+
IPAddress gateway(192, 168, 1, 1);
35+
IPAddress subnet(255, 255, 0, 0);
36+
37+
38+
// telnet defaults to port 23
39+
EthernetServer server(23);
40+
41+
EthernetClient clients[4];
42+
43+
void setup() {
44+
// initialize the Ethernet device
45+
Ethernet.begin(mac, ip, myDns, gateway, subnet);
46+
// start listening for clients
47+
server.begin();
48+
// Open serial communications and wait for port to open:
49+
Serial.begin(9600);
50+
while (!Serial) {
51+
; // wait for serial port to connect. Needed for native USB port only
52+
}
53+
54+
55+
Serial.print("Chat server address:");
56+
Serial.println(Ethernet.localIP());
57+
}
58+
59+
void loop() {
60+
// wait for a new client:
61+
EthernetClient client = server.available();
62+
63+
// when the client sends the first byte, say hello:
64+
if (client) {
65+
66+
boolean newClient = true;
67+
for (byte i = 0; i < 4; i++) {
68+
//check whether this client refers to the same socket as one of the existing instances:
69+
if (clients[i] == client) {
70+
newClient = false;
71+
break;
72+
}
73+
}
74+
75+
if (newClient) {
76+
//check which of the existing clients can be overridden:
77+
for (byte i = 0; i < 4; i++) {
78+
if (!clients[i] && clients[i] != client) {
79+
clients[i] = client;
80+
// clear out the input buffer:
81+
client.flush();
82+
Serial.println("We have a new client");
83+
client.print("Hello, client number: ");
84+
client.print(i);
85+
client.println();
86+
break;
87+
}
88+
}
89+
}
90+
91+
if (client.available() > 0) {
92+
// read the bytes incoming from the client:
93+
char thisChar = client.read();
94+
// echo the bytes back to all other connected clients:
95+
for (byte i = 0; i < 4; i++) {
96+
if (clients[i] && (clients[i] != client)) {
97+
clients[i].write(thisChar);
98+
}
99+
}
100+
// echo the bytes to the server as well:
101+
Serial.write(thisChar);
102+
}
103+
}
104+
for (byte i = 0; i < 4; i++) {
105+
if (!(clients[i].connected())) {
106+
// client.stop() invalidates the internal socket-descriptor, so next use of == will allways return false;
107+
clients[i].stop();
108+
}
109+
}
110+
}

0 commit comments

Comments
 (0)