Step-by-step Usage Instructions
- Make sure you have the SOCK library in your project.
- Add pppoe.tbs and pppoe.tbh files to your project (they are in current_library_set\pppoe\trunk).
- Add #define PPPOE_DEBUG_PRINT 1 to the defines section of the global.tbh file of your project. This way you will "see what's going on". Don't forget to remove this later, after you've made sure that the library operates as expected.
- Add include "pppoe\trunk\pppoe.tbh" to the includes section of the global.tbh file.
- Add pppoe_proc_timer() to the on_sys_timer() event handler code (see "further considerations" below).
- Add pppoe_proc_data() to the on_sock_data_arrival() event handler code.
- Create empty callback function bodies (presumably in the device.tbs): callback_pppoe_ok(), callback_pppoe_failure(), callback_pppoe_pre_buffrq(). Hint: copy from declarations in the pppoe.tbh or from our code example.
- Call pppoe_start() from somewhere. The no-brainer decision is to call from the on_sys_init() event handler. Supply correct ADSL login and password (suggestion: use STG library to keep them). Note that pppoe_start() may fail, so it is wise to check the returned status code.
- Implement meaningful code for the callback_pppoe_ok(). Once it is called, you know that your PPPoE interface is up.
All of the above is illustrated in the code example.
The PPPOE library expects the pppoe_proc_timer() to be called at 0.5 sec intervals. This is the default value which can be changed through the sys.onsystimerperiod property. If your project needs to have the on_sys_timer() event at a different rate, please make sure that pppoe_proc_timer() is still called 2 times/second. For example, if the on_sys_timer() is set to trigger 4 times/second, you need to add "divider" code that only calls pppoe_proc_timer() on every second invocation of the on_sys_timer().