User manual

495
mikoPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
// add PORTD value (LEDs) to reply
tmp := ‘var PORTD= ‘;
result := result + SPI_Ethernet_putString(@tmp);
WordToStr(PORTD, dyna);
result := result + SPI_Ethernet_putString(@dyna);
tmp := ‘;’;
result := result + SPI_Ethernet_putString(@tmp);
// add HTTP requests counter to reply
WordToStr(httpCounter, dyna);
tmp := ‘var REQ= ‘;
result := result + SPI_Ethernet_putString(@tmp);
result := result + SPI_Ethernet_putString(@dyna);
tmp := ‘;’;
result := result + SPI_Ethernet_putString(@tmp);
end
else
if(getRequest[5] = ‘t’) then // if request path name starts
with t, toggle PORTD (LED) bit number that comes after
begin
bitMask := 0;
if(isdigit(getRequest[6]) <> 0) then // if 0 <= bit number <= 9,
bits 8 & 9 does not exist but does not matter
begin
bitMask := getRequest[6] - ‘0’; // convert ASCII to integer
bitMask := 1 shl bitMask; // create bit mask
PORTD := PORTD xor bitMask; // toggle PORTD with xor operator
end;
end;
if(result = 0) then // what do to by default
begin
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;
// return to the library with the number of bytes to transmit
end;
{*
* 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
*
*}