The different source code files for the stack
The
actual TCP/IP stack and the driver for the ethernet chip consists
of the following files:
- enc28j60.c
- enc28j60.h
- ip_arp_udp_tcp.c
- ip_arp_udp_tcp.h
- ip_config.h
- timeout.h
- net.h
The main file you have to interface from an application
point of view is ip_arp_udp_tcp.h. The ip_config.h allows you to
customize the stack and switch off features that you might not
need. This will keep the size always to the minimal. It is
recommended to use the Makefile for compiling the files and thus
keep track of the dependencies. Windows users might want to
customize winmake.bat which will then call the Makefile.
The files websrv_help_functions.c and websrv_help_functions.h contain
useful helper function for parsing URLs or for
URL-encoding/decoding.
DNS and DHCP
The files dnslkup.c and dnslkup.h implement a tiny but very
capable DNS resolver.
The DHCP client is: dhcp_client.c and dhcp_client.h
Examples on how to use the stack
The different examples and applications in this package are:
- server-www-simple/test_OKworks.c -- Example for a basic web server
- server-www-simple/basic_web_server.c -- Example for a web server
- server-www-simple/test_readSiliconRev.c -- Prints the chip revision of the ENC
- server-www-remswitch/main.c -- You can switch a relay on or off a relay via a web-page or via a small udp application (see directory udpcom). The relay is connected via pin PD7. The default password is "secret".
- client-tuxgr-email/test_emailnotify.c -- send email notifications when you connect PD6 to GND. You need a tuxgraphics microcontroller mail account to use this. There is a timeout of 3min to prevent too many mails.
- client-www/test_identi_ca.c -- post a message on identi.ca. To trigger the sending of the message connect PD6 to GND. You need a identi.ca account to use this. There is a timeout of 3min to prevent too many posts.
- client-www/test_web_client.c -- a web client that uploads data to http://tuxgraphics.org/cgi-bin/upld when you ping it once (you can ping it again after 60sec and it will do a new upload).
- client-www-dhcp/test_dhcp_www_client_pushbutton.c -- a web client that uploads data to http://tuxgraphics.org/cgi-bin/upld when you connect PD6 with GND for a moment. This client uses DHCP to configure its self. You can just load the software and plug it to any body's DSL router and it will work.
- client-www-dhcp/test_dhcp_www_client_adc0.c -- a web client that uploads periodically (at power on and then every hour) voltage readings from ADC0 to http://tuxgraphics.org/cgi-bin/upld This client uses DHCP to configure its self. You can just load the software and plug it to any body's DSL router and it will work.
What are those callback functions?
Some functions want a pointer to a function as one of the arguments.
That function gets then called at a later point in time when some
result is available.
Why are we doing this? In a microcontroller the execution has always
to continue (or at least you have to have the possibility to do so).
That way you can still be responsive to other events (key button
events, monitoring of voltages...).
The callback function gets then automatically executed when the
result is ready but in the mean time you could be doing something else
if you wanted.
//Example of a callback function:
void arpresolver_result_callback(uint8_t *ip,uint8_t transaction_number,uint8_t *mac){
uint8_t i=0;
if (transaction_number==TRANS_NUM_GWMAC){
// copy mac address over:
while(i<6){gwmac[i]=mac[i];i++;}
}
}
// a pointer to arpresolver_result_callback is passed to get_mac_with_arp():
get_mac_with_arp(gwip,TRANS_NUM_GWMAC,&arpresolver_result_callback);
Copyright of the software and all diagrams: Guido Socher, tuxgraphics.org
License for all application code: GPL V2
See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
License for the stack: GPL V2
See http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html
Other licenses are available on request.
vim:sw=8:ts=8:si:et