Академический Документы
Профессиональный Документы
Культура Документы
Putting a web server in your embedded widget a NYC Resistor Workshop November 22nd, 2009 Ben Combee http://webduino.googlecode.com
Class Materials
Files on the Flash Drive: Copy of presentation in PDF format Webduino source and example files Wiznet 5100 data sheet HTTP 1.1 specification Arduino Ethernet Library Reference Arduino IDE 0017 for Win/Mac/Linux
Ethernet
Hardware connection using a shared media Each device has an unique 48-bit MAC number Data is formed into frames that contain the source and destination MAC twisted-pair networks have each device directly connected to another device or to a hub/switch supports broadcast mode where every computer on network gets your frame Frames have a simple CRC check to detect corruption
IP (Internet Protocol)
Layer on top of Ethernet Computers are identified with a 4-byte IP address Example: 192.168.42.103 ARP is used to map Ethernet MACs to IP addresses Local network specified using a subnet mask Packets for foreign nets are sent to a gateway TCP is a protocol for making a series of raw packets look like a serial connection with error correction A computer supports multiple connections by mapping each one to a port number 127.0.0.1 is reserved as loopback
IP Addresses
Computers are identified with a 4-byte IP address Example: 192.168.42.103 127.0.0.1 is reserved as loopback 10.x.x.x and 192.168.x.x are private address ranges NAT (Network Address Translation) is used to make private networks talk to the public Internet Home routers usually provide a 192.168.x.x network to your computers all bound into one public Internet IP address
Wiznet: DHCP
DHCP library available now for the Wiznet chip. http://blog.jordanterrell.com/post/Arduino-DHCP-LibraryVersion-04.aspx Requires a bit of RAM, so best used with Arduino boards using the ATMega328 or ATMega1280 chips Better for clients, since you need to know the IP address of your server from other computers
Using AJAX
Embed Javascript code in your page to POST data back to your form Example: AJAX Buzzer You can load scripts and images from well-known locations on net, rather than from Flash memory on device