Step-by-step Usage Instructions
Steps below assume that you are using the NB1010 board (DS101x device) for testing.
- Make sure you have the SOCK library in your project.
2.Add gprs.tbs and gprs.tbh files to your project (they are in current_library_set \gprs\trunk).
Add #define GPRS_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 "gprs\trunk\gprs.tbh" to the includes section of the global.tbh file.
Add gprs_proc_timer() to the on_sys_timer() event handler code (see "further considerations" below).
Add pppoe_proc_sock_data() to the on_sock_data_arrival() event handler code.
Add pppoe_proc_ser_data() to the on_ser_data_arrival() event handler code.
Create empty callback function bodies (presumably in the device.tbs): callback_gprs_ok() , callback_gprs_failure() , callback_gprs_pre_buffrq() . Hint: copy from declarations in the pppoe.tbh or from our code example .
Call gprs_start() from somewhere. The no-brainer decision is to call from the on_sys_init() event handler. Supply correct ATDT line and APN. In our tests on Taiwan Cellular network, we have to use *99# and INTERNET . Your network may require a different string. Note that pppoe_start() may fail, so it is wise to check the returned status code.
Implement meaningful code for the callback_gprs_ok() . Once it is called, you know that your PPP link is up.
All of the above is illustrated in the code example .
The GPRS library expects the gprs_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 gprs_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 gprs_proc_timer() on every second invocation of the on_sys_timer().
If you are using an external GPRS modem, you need to add #define GPRS_MODULE_EXTERNAL 1 to global.tbh.
Depending on how you connect the GPRS modem, you may also need to add the following custom defines: