Datasheet
'*
'* put the string pointed to by s to the ENC transmit buffer
'*
sub function putString(dim byref s as byte[100]) as word
result = 0
while(s[result] <> 0)
SPI_Ethernet_putByte(s[result])
Inc(result)
wend
end sub
'*
'* this sub function is called by the library
'* the user accesses to the HTTP request by successive calls to
SPI_Ethernet_getByte()
'* the user puts data in the transmit buffer by successive calls to
SPI_Ethernet_putByte()
'* the sub function must return the length in bytes of the HTTP reply,
or 0 if nothing to transmit
'*
'* if you don"t need to reply to HTTP requests,
'* just define this sub function with a return(0) as single state-
ment
'*
'*
sub function Spi_Ethernet_UserTCP(dim byref remoteHost as byte[4],
dim remotePort, localPort, reqLength
as word) as word
dim len_ as word ' my reply length
bitMask as byte ' for bit mask
tmp as byte[5] ' to copy const array to ram for memcmp
len_ = 0
if(localPort <> 80) then ' I listen only to web request on port 80
result = 0
exit
end if
' get 10 first bytes only of the request, the rest does not mat-
ter here
for len_ = 0 to 9
getRequest[len_] = SPI_Ethernet_getByte()
next len_
getRequest[len_] = 0
len_ = 0
while (httpMethod[len_] <> 0)
tmp[len_] = httpMethod[len_]
Inc(len_)
wend
len_ = 0
385
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6