Datasheet

* 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 HTTP reply,
or 0 if nothing to transmit
*
* if you don't need to reply to HTTP requests,
* just define this function with a return(0) as single statement
*
*}
function SPI_Ethernet_UserTCP(var remoteHost : array[4] of byte;
remotePort, localPort, reqLength : word)
: word;
var len : word ; // my reply length
bitMask : byte ; // for bit mask
tmp: array[5] of byte; // to copy const array to ram for mem-
cmp
begin
len := 0;
if(localPort <> 80) then // I listen only to web request on port 80
begin
result := 0;
exit;
end;
// get 10 first bytes only of the request, the rest does not mat-
ter here
for len := 0 to 9 do
begin
getRequest[len] := SPI_Ethernet_getByte() ;
end;
getRequest[len] := 0 ;
len := 0;
while (httpMethod[len] <> 0) do
begin
tmp[len] := httpMethod[len];
Inc(len);
end;
len := 0;
if(memcmp(@getRequest, @tmp, 5) <> 0) then // only GET method
is supported here
begin
result := 0 ;
exit;
end;
httpCounter := httpCounter + 1 ; // one more request done
396
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6