GPRS library's operation is persistent: once you start it by calling gprs_start() , it will "persist" to keep PPP link established. No matter how many times the link fails, the library will keep trying. If the successfully established PPP link fails, the library will attempt to reestablish the link. This can only be halted by calling gprs_stop() .
GPRS library is buffer-hungry. Even if you set GPRS_PAYLOAD_SIZE to 1, you will need 10 buffer pages for the GPRS library to operate. With default payload size of 4, this increases to 25 buffer pages. GPRS_PAYLOAD_SIZE defines the maximum size of TCP and UDP packets that the PPP interface will be able to handle. Unless you specifically want to send out large UDP packets, it is actually OK to set the payload size to the minimum — GPRS links are slow and you won't feel any performance decrease just because you limit the size of packets.
Buffer space is allocated when gprs_start() is called. The library will check if the required buffer space is available and call callback_ppp_pre_buffrq() if more space is needed. Buffer pages allocated to the PPP library will only be released if gprs_stop() is called.
Successul PPP link establishment is a multi-step process and involves link configuration using LCP protocol, followed by the login and the configuration of device's IP address. To observe the process, add #define GPRS_DEBUG_PRINT 1 to the defines section of the global.tbh file of your project (and don't forget to remove this later).
Once the PPP link is successfully established, the library will set ppp.ip and call callback_gprs_ok() . The library will then start monitoring PPP link's "health". The library will periodically send echo request packets and expect echo replies from the other end. If this times out, the library will assume that the PPP link has failed, call gprs_failure() , and attempt to reestablish the link.
If your application calls pppoe_stop() , the library will apply the hardware reset to the GPRS module (provided that GPRS_MODULE_EXTERNAL is 0), release all buffers, and go into the idle state until gprs_start() is called again.