Reseting modem periodically

Hi all!

I want to reset my modems periodically, more or less each 3 hours. The way that I have thought is inserting AT+CFUN=0 and AT+CFUN=1 commands when changing to AT mode with “+++” command. It would be something similar to this:

bool V24M_Ctrl_Handler (adl_fcmEvent_e event)
if (event == ADL_FCM_EVENT_V24_AT_MODE_EXT)
//Change data mode to AT mode.
TRACE ((LVL_SERIAL, "V24M_Ctrl_Handler: V24 link received +++ in data mode"));
t2r_SerialCmdMode = TRUE;

adl_atCmdCreate ("AT+CFUN=0", FALSE, NULL,NULL);
adl_atCmdCreate ("AT+CFUN=1", FALSE, NULL,NULL);



Do you think it will work?? Is there any easier solution for performing this reset by code??


You should certainly use AT+CFUN=0 first - to ensure that the unit detaches cleanly from the network.
But be sure to wait for the OK response!

To then do the reboot, you can use adl_errHalt

But, rather than just arbitrarily reboot every 3 hours, wouldn’t it be better to have some “intelligence” to determine when a reboot seems necessary?

Thank you, I will take care about responses :wink: One doubt also is if the command AT+CFUN=1 will be executed as the program is stopped with the AT+CFUN=0. Anyway I will try and I will post my results.

We want to reboot each some time because we are working with these modems in Qatar, and there, the GPRS provider don’t give us fixed IP’s for their SIM cards (only one telecom provider in the whole country by the moment), so after a time we are losing sessions with the IP’s and it is no longer reachable and also the provider don’t give us any solution. Performing a reboot starts a new GPRS session with another IP and then communication starts working again. For us we can interchange data each 3 or 4 hours, this is not a problem, and there is a little bit hurry in solving these issues.

Rebooting the whole unit is a bit of a sledgehammer approach!

All you need to do is to close the GPRS session, and then start a new one.

Note that radio links are inherently unreliable, so your application needs to be able to cope with losing the session anyhow.
Rebooting should be a last resort - not a regular event!

you can catch the WIP_BEV_DISCONNECTED if you are using wip library. At that time you can close the session completly and connect gprs again. Reseting doesnt seem the best solution.
And why do you need to switch AT mode before sending AT+CFUN= commands?

Not necessarily.

Depending on how the network actually does it, the only way to detect that it has timed out may be that your next communication attempt fails.

But, as I said earlier, your application needs to be designed to cope with that anyhow…



Awneil, as you say, I can only detect the time out when my next attempt fails. The problem also is that we don’t know how the network release the session and then I don’t know where to “catch” this end of session. So as reseting all will give us a new IP, that’s the way that we have thought by the moment.

It is not possible to send any AT command while in data mode, isn’t it? At least I tried and didn’t get anything. Only the AT command is send as it is (plain text) through TCP port opened for communication, but it is not parsed as an AT command.

I also don’t know if I am really handling WIP_BEV_DISCONNECTED or WIP_BEV_STOPPED or WIP_BEV_CONN_FAILED events. I have these events in “Hdlr_GPRS_Bearer” function, which is executed using a “wip_bearerOpen” call. Then it is correctly executed when connecting the first time, and the event that I receive is WIP_BEV_CONNECTED. After this I change port speed to 9600 and no flow control (because of speed of my serial equipment) and then I suppose that the function is never executed again, because wip_bearerOpen function ended his execution. Then do you think that these events are being hadled anyway or maybe I need to handle them in other part of the code?

By the moment I continue trying with the reseting of the modem solution. Thank you anyway :wink:

You really don’t need to do that!

Why don’t you just assume that the session will not be held open and, therefore, close it immediately after sending;
Then, next time you need to send, you open a new session - no need for rebooting!

It is not possible to send from an external application - but I think it should be possible through ADL?

adl_cmdCreate function can execute AT commands without switching AT mode. If you use an external application to perform rebooting, then you should send +++ first. But are you using external application to perform rebooting? If not, then you can use adl_cmdCreate i think.

On the other hand, i didnt understand your gprs connection and flow control flowchart. WIP_BEV_DISCONNECTED event is not trustful? or cant you catch it?