Reseting an application upon gprs disconnect

How can I know when my provider closes the gprs connection. When that occurs, I want to reconnect and restart my application (2nd option is to reset the modem which will automatically reconnect and restart app, but data will be lost). What APIs are needed to be called for reconnecting.
Thank you for your help.

More detailed description follows.
I’m exchanging messages between a Fastrack Supreme module (doesn’t have a public IP address) and a PC with fixed public IP address on a fixed period basis.

Every period (let’s say 24 hours) the module sends it’s IP address to the server. Upon recieval, the PC connects to the module and exchanges messages. The application is based on the OpenAT TCP/IP Server example config files.

But, normally, my provider closes the gprs connection every know and then (module doesn’t have a permanent IP address). When that happens, I want to reconnect and inform the PC about the new IP address (asynchronously).

maybe i’m thinking too simple, but why don’t you push the data to the server instead of letting the server pull it from the module?

your application (as descripted) does not seem to call for a permanent conenction?

I’m sorry. Forgot to mention that module should be accessible all the time (requirement for future use).

from your information i gather that you use the wip-libraries.

When the gprs connection is disconnected, you receive an event indicating that the gprs connection is closed.

Also, just knowing the ip isn’t enough for the ‘server’ to connect to the gprs module, because (as you indicated) you don’t have a public ip.
Your modem (propably) lives behind a NAT router, so if you need to initiate a data transfer from the server, you need to keep a channel open to the server.
A channel is automaticaly opened when you initiate a data transfer from the modem to the server, but it will be closed if you leave it idle for too long (propably about 15 minutes).

But the modem may not be able to detect that the IP connection from the GPRS network to the server has been closed…

That’s the bit that is unlikely to be detectable to the modem!

The only thing you can do is attempt to use it and, if it fails, close and then restart the entire GPRS session.

You need to design for this anyhow, since radio links are inherently unreliable!

I don’t understand “you need to keep a channel open to the server”? You mean TCP listener? Doesn’t it stay open all the time?

The apllication on the module now works like this. Every period:

  • the TCP server (listener) from the previous session is closed
  • new TCP server (listener) is opened
  • new client is opened, the client sends current module IP adress, the client closes
  • PC connects to the module, TCP server (listener) spawns a new client (on PC initiative), the messages are exchanged, spawned client is closed

I am going to the following:
Upon WIP_BEV_IP_DISCONNECTED event call wip_bearerStart (b) again,restart the server (close the current one, open a new one) and send the new IP adress. Is this a good approach? Is it actually neccesary to close TCP server (listener) all the time?

Hiya,

I had problems with the WIP API determining that the GPRS connection had failed/been disconnected/gone away. However, I found that if you subscribe to the lower level GPRS notifications (using adl_gprsSubscribe()), you will get a ADL_GPRS_EVENT_ME_UNREG event when the GPRS connection goes away, and a ADL_GPRS_EVENT_ME_ATTACH event when the device is re-attached to the network.

I trap the ADL_GPRS_EVENT_ME_UNREG event and use it to call the wip_bearerStop() function to clean up the WIP API.
I trap the ADL_GPRS_EVENT_ME_ATTACH event and use it to restart my GPRS connection process (via the WIP API).

Hope this helps.

ciao, Dave

But these relate only to losing GPRS registration and attachment.

In my experience, when the service provider times-out the IP connection, you remain GPRS registered & attached - there is no way to detect that the IP connection has gone other than to attempt an end-to-end connection, and instigate recovery action if it fails.

OK, for now when WIP_BEV_IP_DISCONNECTED, ADL_GPRS_EVENT_ME_UNREG or ADL_GPRS_EVENT_ME_ATTACH triggers I restart the bearer ( wip_bearerStop( b);wip_bearerStart( b); )

I’ll test it for some time, but according to awneil’s experience it won’t work:)

awneil, what do you use for testing end-to-end connection? My idea is simply to ping the PC server every xy hours and react to WIP_CEV_PING with timeout true or WIP_CEV_ERROR.

…Or maybe not. Looks like the PING service isn’t working correctly: viewtopic.php?f=16&t=1982
Maybe set up a dumb client which will act as a ping, and set the server on the PC side to ignore that client…?

I get this event every time I initiate connection to gprs, and sometimes during the connection. Thus, I don’t understand why should I restart connection process when it happens?

Since we are already at this topic of GPRS disconnection,
I’m currently testing this wavecom unit that i have onhand Fastrack Supreme 10, Q2687, using InternetConnection sampler provided by Wavecom itself.

It’s built on a 6.6.3c platform and using the default values. I’ve made some minor changes to accommodate with GPIO into this data sent in a string

I noticed that this doesn’t do a continuous check on the connectivity of the bearer. This wavecom is currently being powered in my car, and data’s sent back to my own server. I have a transaction log of the event as well.

Once the module goes out of GPRS range, or the socket in the server is closed, the module doesn’t detect it AT ALL and it doesn’t close the GPRSBearer or do anything. It will continue sending data to the channel without any error indication.

I’m having a hard time with this WIP library and i was wondering if anyone knows how to implement the reconnect protocol for the InternetConnection sample once it’s out of GPRS range or a socket close