User manual

434
mikoBasic PRO for PIC32
MikroElektronika
‘ add PORTB value (buttons) to reply
txt = “var PORTB=”
result = result + Spi_Ethernet_putString(@txt)
WordToStr(PORTB, dyna)
result = result + Spi_Ethernet_putString(@dyna)
txt = “;”
result = result + Spi_Ethernet_putString(@txt)
‘ 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
‘ *