User manual
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
495
‘ get 10 rst bytes only of the request, the rest does not matter here
for i = 0 to 10
getRequest[i] = Spi_Ethernet_getByte()
next i
getRequest[i] = 0
‘ copy httpMethod to ram for use in memcmp routine
for i = 0 to 4
txt[i] = httpMethod[i]
next i
if(memcmp(@getRequest, @txt, 5) <> 0) then ‘ only GET method is supported here
result = 0
exit
end if
Inc(httpCounter) ‘ one more request done
if(getRequest[5] = “s”) then ‘ if request path name starts with s, store
dynamic data in transmit buffer
‘ the text string replied by this request can be interpreted as javascript
statements
‘ by browsers
result = SPI_Ethernet_putConstString(@httpHeader) ‘ HTTP header
result = result + SPI_Ethernet_putConstString(@httpMimeTypeScript) ‘ with text
MIME type
‘ add AN0 value to reply
WordToStr(ADC1_Get_Sample(0), dyna)
txt = “var AN0=”
result = result + Spi_Ethernet_putString(@txt)
result = result + Spi_Ethernet_putString(@dyna)
txt = “;”
result = result + Spi_Ethernet_putString(@txt)
‘ add AN1 value to reply
WordToStr(ADC1_Get_Sample(1), dyna)
txt = “var AN1=”
result = result + Spi_Ethernet_putString(@txt)
result = result + Spi_Ethernet_putString(@dyna)
txt = “;”
result = result + Spi_Ethernet_putString(@txt)
‘ 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)