300
Part II: Advanced Hacks, Tools, and Techniques
Exhibit B: Schematic Diagram
Exhibit C: SitePlayer Code
Listing 1: coffee.spd
;
; These are initial variables that you can place in your system
;
;$Devicename sets the name or description of the device
$Devicename “Coffee Machine Web server”
;$DHCP on sets SitePlayer to find its IP address from a DHCP server
$DHCP on
;$DownloadPassword sets password for downloading web pages and firmware
$DownloadPassword “”
;$SitePassword sets password for browsing web pages
$SitePassword “”
;$InitialIP sets SitePlayer’s IP address to use if no DHCP server is available
$InitialIP “192.168.1.250”
;$PostIRQ on sets SitePlayer to generate a low level IRQ on pin 11
$PostIRQ off
;$Sitefile sets the binary image filename that will be created
$Sitefile “E:\Hacking Book\coffee_machine_hack\coffee\coffee.spb”
Exhibit B
ch15_coffee.indd 300
1/21/2002 1:36:02 PM
301
Chapter 15, How to Build an Internet Coffeemaker
;$Sitepath sets the root path of the web pages for this project
$Sitepath “E:\Hacking Book\coffee_machine_hack\coffee”
;$Include sets the name of a file to include during make process
$Include “E:\Hacking Book\coffee_machine_hack\coffee\pcadef.inc”
$Include “E:\Hacking Book\coffee_machine_hack\coffee\udpsend_def.inc”
Listing 2: Index.htm
<html>
<body bgcolor=”#99FFFF”>
<h1 align=”center”>Coffee Machine Web Server</h1>
<hr>
<hr>
<a href=”water.spi?IO0=0&SPIaddr=%00&IO3=0&SPIBus=%1E%00&IO3=1”>check water</a>
<a href=”refresh_index.spi?IO0=0&SPIaddr=%00&IO3=0&SPIBus=%1A%00&IO3=1”>check temperature</a>
; this is the command that triggers the SPI data transaction to and from the A/D converter
<!--a href=”index.spi?IO4=0&IO4=1”>
<!--the value of memory location hex 03 is ^temper<br>
<!--value of 01 is ^water<br>
<br>
temperature is ^water*2
<br>
<!--water is ^temper#C0h--!>
<!--- input type=”text” name=”SPIbus” maxlength=”80” size=”80” ---!><br>
<!--press the link above to ectivate the transaction<br>
<hr>
<hr>
</body>
</html>
Listing 3: SitePlayer index.spi
HTTP/1.0 302 Found
Location: /index.ht
Listing 4: refresh_index.htm
<html>
<head>
<meta http-equiv=”refresh”
content=”0;url=index.spi?IO0=0&SPIaddr=%00&IO3=0&SPIBus=%1A%00&IO3=1”>
<title>test</title>
</head>
<body bgcolor=”#99FFFF”>
<h1 align=”center”>Coffee Machine Web Server</h1>
<hr>
<hr>
<a href=”water.spi?IO0=0&SPIaddr=%00&IO3=0&SPIBus=%1E%00&IO3=1”>check water</a>
<a href=”refresh_index.spi?IO0=0&SPIaddr=%00&IO3=0&SPIBus=%1A%00&IO3=1”>check temperature</a>
Listing 1: coffee.spd (continued)
Exhibit C
ch15_coffee.indd 301
1/21/2002 1:36:02 PM
302
Part II: Advanced Hacks, Tools, and Techniques
^temper<br>
^water<br>
<br>
<br>
<br>
<hr>
<hr>
</body>
</html>
Listing 5: refresh_index.spi
HTTP/1.0 302 Found
Location: /refresh_index.htm
Listing 6: water.htm
<html>
<body bgcolor=”#99FFFF”>
<h1 align=”center”>Coffee Machine Web Server</h1>
<hr>
<hr>
<a href=”water.spi?IO0=0&SPIaddr=%00&IO3=0&SPIBus=%1E%00&IO3=1”>check water</a>
<a href=”refresh_index.spi?IO0=0&SPIaddr=%00&IO3=0&SPIBus=%1A%00&IO3=1”>check temperature</a>
<!--a href=”index.spi?IO4=0&IO4=1”>
<br>
<br>
water is ^water
<!--- input type=”text” name=”SPIbus” maxlength=”80” size=”80” ---!><br>
<!--press the link above to ectivate the transaction<br>
<hr>
<hr>
</body>
</html>
Listing 7: water.spi
HTTP/1.0 302 Found
Location: /water.htm
Listing 8: pcadef.inc
;
; Definitions for SitePlayer standalone direct port I/O
; to use these items they can be viewed by doing a ^objectname in your HTML file
; or they can be input by making an object of the same name in a form
;
; Some objects cannot be viewed
;
; If you do not need all the objects, you should NOT include this complete file
; even if your program does not use a particular object by name. If you include
Listing 4: refresh_index.htm (continued)
Exhibit C
ch15_coffee.indd 302
1/21/2002 1:36:02 PM
303
Chapter 15, How to Build an Internet Coffeemaker
; this file in its entirety, someone could send a URL request with the name of
; an object and make changes to your SitePlayer.
;
; So only define the objects you specifically intend to use
;
org 0ff00h
p1 ds 1 ;Port 1 all 8 bits
org 0ff01h
cmod ds 1 ;PCA Counter Mode
org 0ff02h
ccon ds 1 ;PCA Counter control
org 0ff03h
ch ds 1 ;PCA Counter High
org 0ff04h
cl ds 1 ;PCA Counter Low
org 0ff05h
ccapm0 ds 1 ;Module 0 Mode
org 0ff06h
ccapm1 ds 1 ;Module 1 Mode
org 0ff07h
ccapm2 ds 1 ;Module 2 Mode
org 0ff08h
ccapm3 ds 1 ;Module 3 Mode
org 0ff09h
ccap0h ds 1 ;Module 0 Capture High
org 0ff0ah
ccap1h ds 1 ;Module 1 Capture High
org 0ff0bh
ccap2h ds 1 ;Module 2 Capture High
org 0ff0ch
ccap3h ds 1 ;Module 3 Capture High
org 0ff0dh
ccap0l ds 1 ;Module 0 Capture Low
org 0ff0eh
ccap1l ds 1 ;Module 1 Capture Low
org 0ff0fh
ccap2l ds 1 ;Module 2 Capture Low
Listing 6: water.htm (continued)
Exhibit C
ch15_coffee.indd 303
1/21/2002 1:36:02 PM
304
Part II: Advanced Hacks, Tools, and Techniques
org 0ff10h
ccap3l ds 1 ;Module 3 Capture Low
org 0ff11h
io0 ds 1 ;Port 1 Bit number 0
org 0ff12h
io1 ds 1 ;Port 1 Bit number 1
org 0ff13h
io2 ds 1 ;Port 1 Bit number 2
org 0ff14h
io3 ds 1 ;Port 1 Bit number 3
org 0ff15h
io4 ds 1 ;Port 1 Bit number 4
org 0ff16h
io5 ds 1 ;Port 1 Bit number 5
org 0ff17h
io6 ds 1 ;Port 1 Bit number 6
org 0ff18h
io7 ds 1 ;Port 1 Bit number 7
org 0FF19h
COM ds 128 ;serial port output (only takes up really one byte)
org 0FF1Ah
Baud dw 0 ;baud rate counter register (WORD)
org 0FF1Ch
SPIbus ds 128 ;SPI bus commands (only takes up really one byte)
org 0FF1Dh
SPIaddr db 0 ;destination of SPI incoming data
org 0FF1Eh
UDPsend db 0 ;flag to send out a UDP message
org 0FF1Fh
HalfSec db 0 ;half second (0.50135) down counter stops when 0
org 0FF20h
UDPrcvr db 0 ;enable UDP receives or not
org 01h
water db 0 ; place to get at incoming SPI data
org 03h
temper db 0
Listing 8: pcadef.inc (continued)
Exhibit C
ch15_coffee.indd 304
1/21/2002 1:36:02 PM

Get Hardware Hacking Projects for Geeks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.