User manual

496
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
‘ add PORTD value (LEDs) to reply
txt = “var PORTD=”
result = result + Spi_Ethernet_putString(@txt)
WordToStr(PORTD, dyna)
result = result + Spi_Ethernet_putString(@dyna)
txt = “;”
result = result + Spi_Ethernet_putString(@txt)
‘ add HTTP requests counter to reply
WordToStr(httpCounter, dyna)
txt = “var REQ=”
result = result + Spi_Ethernet_putString(@txt)
result = result + Spi_Ethernet_putString(@dyna)
txt = “;”
result = result + Spi_Ethernet_putString(@txt)
else
if(getRequest[5] = “t”) then if request path name starts with t, toggle PORTD
(LED) bit number that comes after
bitMask = 0
if(isdigit(getRequest[6]) <> 0) then if 0 <= bit number <= 9, bits 8 & 9 does
not exist but does not matter
bitMask = getRequest[6] - “0” ‘ convert ASCII to integer
bitMask = 1 << bitMask ‘ create bit mask
PORTD = PORTD xor bitMask ‘ toggle PORTD with xor operator
end if
end if
end if
if(result = 0) then ‘ what do to by default
result = SPI_Ethernet_putConstString(@httpHeader) ‘ HTTP header
result = result + SPI_Ethernet_putConstString(@httpMimeTypeHTML) with HTML
MIME type
result = result + SPI_Ethernet_putConstString(@indexPage) ‘ HTML page rst part
result = result + SPI_Ethernet_putConstString(@indexPage2) HTML page second
part
end if
‘ return to the library with the number of bytes to transmit
end sub
‘ *
‘ * this function is called by the library
‘ * the user accesses to the UDP request by successive calls to Spi_Ethernet_getByte()
‘ * the user puts data in the transmit buffer by successive calls to Spi_Ethernet_putByte()
‘ * the function must return the length in bytes of the UDP reply, or 0 if nothing to transmit
‘ *
‘ * if you don’t need to reply to UDP requests,
‘ * just dene this function with a return(0) as single statement
‘ *
‘ *
sub function Spi_Ethernet_UserUDP(dim byref remoteHost as byte[4],
dim remotePort, destPort, reqLength as word, dim byref
ags as TEthPktFlags) as word