DHCP Library

A warning note icon.This section is currently being reworked to add more detailed content. We apologize for the inconvenience. If you need immediate assistance, please contact Tibbo Support.


The DHCP library implements a DHCP client on Ethernet (net.) and Wi-Fi (wln.) network interfaces. The DHCP protocol is used for automatic configuration of your device's IP address, netmask, and gateway IP address. More on the protocol here: http://en.wikipedia.org/wiki/Dhcp.

The library is capable of running DHCP clients on both network interfaces concurrently. The library is event-based and non-blocking — it quietly runs in the background and takes a minimal amount of CPU time.

Library Info

Supported platforms:

Any platform with at least the Ethernet (net.) or Wi-Fi (wln.) interface except for the EM202.

Files to include:

dhcp.tbs, dhcp.tbh (from current_library_set\dhcp\trunk\).

Dependencies:

SOCK library library;

You may also need the WLN library

API procedures:

Use API procedures to interact with the library.

dhcp_get_info() — returns library-specific information (such as required buffer space).

dhcp_start() — starts the DHCP client on the specified network interface.

dhcp_stop() — stops the DHCP client on the specified network interface.

Event procedures:

Call event procedures from corresponding event handlers, as described here.

dhcp_proc_timer() — call this from the on_sys_timer() event handler.

dhcp_proc_data() — call this from the on_sock_data_arrival() event handler.

Callback procedures:

Implement the bodies of callback procedures elsewhere in your project.

callback_dhcp_ok() — called when the library completes successfully on one of the interfaces.

callback_dhcp_failure() — called when the library fails on one of the interfaces after DHCP_MAX_RETRIES.

callback_dhcp_pre_clear_ip() — called when the library is about to set the interface's IP to 0.0.0.0.

callback_dchp_pre_buffrq() — called when the library needs to allocate buffer space and the required space is not available.

callback_dhcp_buff_released() — called when the library no longer needs buffers and released them.

Required buffer space:

Six buffer pages. These are utilized when needed and released when the DHCP client completes its job. The amount of buffer space needed is constant and does not depend on the number of network interfaces involved.


DHCP Library

Library Info