User manual

493
mikoPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
‘str=””;’+
‘for(i=0;i<4;i++)’+
‘{str+=”<tr><td bgcolor=yellow>LED #”+i+”</td>”;’+
‘if(PORTD&(1<<i)){str+=”<td bgcolor=red>ON”;}’+
‘else {str+=”<td bgcolor=#cccccc>OFF”;}’+
‘str+=”</td><td><a href=/t”+i+”>Toggle</a></td></tr>”;}’+
‘document.write(str);’+
‘</script>’+
‘</table></td></tr></table>’+
‘This is HTTP request #<script>document.write(REQ)</script></BODY></
HTML>’;
var getRequest : array[15] of byte; // HTTP request buffer
dyna : array[30] of char; // buffer for dynamic response
httpCounter : word; // counter of HTTP requests
{*******************************************
* user dened functions
*}
{*
* this 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 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 dene this function with a return(0) as single statement
*
*}
function SPI_Ethernet_UserTCP(var remoteHost : array[4] of byte;
remotePort, localPort, reqLength : word; var ags:
TEthPktFlags) : word;
var i : word; // my reply length
bitMask : byte; // for bit mask
tmp: string[11]; // to copy const array to ram for memcmp
begin
result := 0;
// should we close tcp socket after response is sent?
// library closes tcp socket by default if canCloseTCP ag is not reset here
// ags.canCloseTCP := 0; // 0 - do not close socket
// otherwise - close socket
if(localPort <> 80) then // I listen only to web request on port 80
begin
result := 0;
exit;
end;