nguyenbahuong / smslib

Automatically exported from code.google.com/p/smslib
0 stars 0 forks source link

Poll the modem in case cnmi emulator is disabled #475

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
smslib receives inbound messages either via unsolicited notifications or via 
the cnmi emulator.
If unsolicited notification mode is active the cnmi emulator is disabled.
I suggest to do some occasional polling of the modem to be sure no message has 
been missed.
I propose a minor modification to the process method of the 
AModemDriver.KeepAlive class

Updated code (my modifications between WIM STEVENS - of course this indication 
may be removed if the change is accepted)

public void process() throws Exception
        {
            try
            {
                if (!isConnected()) return;
                if (getGateway().getStatus() == GatewayStatuses.STARTED)
                {
                    synchronized (getSYNCCommander())
                    {
                        if (!isConnected()) return;
                        try
                        {
                            Logger.getInstance().logDebug("Keep alive check.", null, getGateway().getGatewayId());
                            if (!getGateway().getATHandler().isAlive()) getGateway().setStatus(GatewayStatuses.RESTART);
                            // Wim Stevens

                            // Wake up the async message processor if cnmi emulator is disabled
                            if (! getCnmiEmulationProcessor().isEnabled() ) {
                                getAsyncMessageProcessor().setProcess();
                            }
                            // End of Wim Stevens
                        }
                        catch (Exception e)
                        {
                            getGateway().setStatus(GatewayStatuses.RESTART);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logger.getInstance().logError("ModemDriver: KeepAlive Error.", e, getGateway().getGatewayId());
                getGateway().setStatus(GatewayStatuses.RESTART);
            }
        }

Original issue reported on code.google.com by wim.stev...@gmail.com on 20 Mar 2012 at 10:24

GoogleCodeExporter commented 9 years ago

Original comment by T.Delenikas on 22 Mar 2012 at 8:48

GoogleCodeExporter commented 9 years ago
r2334

Original comment by T.Delenikas on 22 Mar 2012 at 9:05

GoogleCodeExporter commented 9 years ago

Original comment by T.Delenikas on 31 Mar 2012 at 8:03