Mikroelektronika MIKROE-724 データシート
492
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
SPI_Ethernet_renewDHCP
Prototype
sub function SPI_Ethernet_renewDHCP(dim tmax as byte) as byte
Description This is DHCP module routine. It sends IP address lease time renewal request to DHCP server.
Parameters -
Parameters -
tmax
: time in seconds to wait for an reply.
Returns
-
1
- upon success (lease time was renewed).
-
0
- otherwise (renewal request timed out).
Requires
Ethernet module has to be initialized. See SPI_Ethernet_Init.
Example
while true
...
if(SPI_Ethernet_doDHCPLeaseTime() <> 0) then
SPI_Ethernet_renewDHCP(5) ‘ it’s time to renew the IP address lease,
with 5 secs for a reply
end if
...
wend
Notes
None.
Library Example
This code shows how to use the Ethernet mini library:
- the board will reply to ARP & ICMP echo requests
- the board will reply to UDP requests on any port:
- returns the request in upper char with a header made of remote host IP & port number
- the board will reply to HTTP requests on port 80, GET method with pathnames:
- / will return the HTML main page
- /s will return board status as text string
- /t0 ... /t7 will toggle RD0 to RD7 bit and return HTML main page
- all other requests return also HTML main page.
Main program code:
program HTTP_Demo
‘ ***********************************
‘ * RAM variables
‘ *
‘ mE ehternet NIC pinout
dim
SPI_Ethernet_Rst as sbit at LATF0_bit
SPI_Ethernet_CS as sbit at LATF1_bit
SPI_Ethernet_Rst_Direction as sbit at TRISF0_bit
SPI_Ethernet_CS_Direction as sbit at TRISF1_bit
‘ end ethernet NIC definitions
dim myMacAddr as byte[6] ‘ my MAC address
myIpAddr as byte[4] ‘ my IP address