User manual
540
mikoC PRO for dsPIC
MikroElektronika
SPI_Ethernet_24j600_doDHCPLeaseTime
SPI_Ethernet_24j600_renewDHCP
Prototype
unsigned int SPI_Ethernet_24j600_doDHCPLeaseTime();
Description This is DHCP module routine. It takes care of IP address lease time by decrementing the global lease
time library counter. When this time expires, it’s time to contact DHCP server and renew the lease.
Parameters None.
Returns - 0 - lease time has not expired yet.
- 1 - lease time has expired, it’s time to renew it.
Requires Ethernet module has to be initialized. See SPI_Ethernet_24j600_Init.
Example
while(1) {
...
if (SPI_Ethernet_24j600_doDHCPLeaseTime())
... // it’s time to renew the IP address lease
}
Notes None.
Prototype
unsigned int SPI_Ethernet_24j600_renewDHCP(unsigned char tmax);
Description This is DHCP module routine. It sends IP address lease time renewal request to DHCP server.
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_24j600_Init.
Example
while(1) {
...
if (SPI_Ethernet_24j600_doDHCPLeaseTime())
SPI_Ethernet_24j600_renewDHCP(5); // it’s time to renew the IP address
lease, with 5 secs for a reply
...
}
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.
Copy Code To Clipboard