Anatomy of Tibbo Libraries

Top  Previous  Next

Most Tibbo libraries are supplied as a pair of files — a .tbs file with all the code, and a .tbh header file with declarations. Both must be added to your project.

Tibbo libraries consist of a set of procedures (subs and functions) that typically fall into three categories:

API procedures provide a way for your program to control and interact with the library. For example, the DHCP library has a dhcp_start() function that launches the DHCP client on the specified network interface. It is usually up to you to select when and how to invoke API procedures.
Event procedures must be called from corresponding event handlers and you don't have any leeway in how you implement this. Each event procedure must be properly called, or the library will not work correctly. Typically, you only need to call the procedure without any additional conditional code surrounding the call. If several libraries "hook" onto the same event then you can call event procedures of different libraries in any order.
Callback procedures have their bodies outside of their library. That is, the libraries will expect you to create the bodies for callback procedures elsewhere in your code (and may we suggest that you choose to have them in the device.tbs file of your project). Callback procedures are used by libraries to inform your "other code" of events happening within the library. For example, the DHCP library calls the callback_dhcp_ok() procedure whenever a DHCP process completes successfully. Arguments for this procedure carry the newly obtained IP and related parameters. You can then place necessary code within callback_dhcp_ok(). The is supposed to update your device's IP, etc. according to the data supplied by the DHCP library.


Virtually every library has a number of defines located in the .tbh (header) file of the library. Defines determine how the library operates — they are library "options". Each define looks like this:






Libraries that come with configurators take care of all defines automatically. Just edit the stuff in the configurator and you are done. Some libraries don't have configurators, mostly because there isn't much to configure. With such libraries you need to add your own #define statements as described in the documentation.

Do not edit library header files! Instead, put your #define statements into the global.tbh file, like this:





#define DHCP_DEBUG_PRINT 1 'this overrides the default value, which is 0



include "dhcp\trunk\dhcp.tbh"