nguyenbahuong / smslib

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

Log the signal strength and network operator name when smslib is started #477

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I propose to log some additional useful info when smslib is started:
- signal strength
- telco operator name

I modified the StartGateway method in ModemGateway class.

Here is the code

public void startGateway() throws TimeoutException, GatewayException, 
IOException, InterruptedException
    {
        Logger.getInstance().logInfo("Starting gateway, using " + getATHandler().getDescription() + " AT Handler.", null, getGatewayId());
        getDriver().connect();
        // Wim Stevens
        // Log the signal strength 
        String signal = getATHandler().getSignalLevel();
        Logger.getInstance().logInfo("Signal level/bit error rate: " + signal , null, getGatewayId());
        // Log the network registration
        String networkRegistration = getATHandler().getNetworkRegistration();
        Logger.getInstance().logInfo("Network registration: " + networkRegistration , null, getGatewayId());
        String networkOperator = getATHandler().getNetworkOperator();
        Logger.getInstance().logInfo("Network operator: " + networkOperator , null, getGatewayId());
        // End Wim Stevens
        super.startGateway();
        Logger.getInstance().logInfo("Gateway started.", null, getGatewayId());
    }

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

GoogleCodeExporter commented 9 years ago

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

GoogleCodeExporter commented 9 years ago
What is this? "getATHandler().getNetworkOperator();"

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

GoogleCodeExporter commented 9 years ago
r2335 (pending clarification)

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

GoogleCodeExporter commented 9 years ago
I thought that getNetworkOperator was as standard method of Smslib.  Perhaps I 
have added the method myself:

    /* (non-Javadoc)
     * @see org.smslib.modem.athandler.AATHandler#getNetworkOperator()
     */
    @Override
    public String getNetworkOperator() throws GatewayException,
            TimeoutException, IOException, InterruptedException {
        getModemDriver().write("AT+COPS?\r");
        return (getModemDriver().getResponse());
    }
It gives me the name of the operator.  Could be of interest when you live near 
the border of a country.  To have a confirmation that you are not working in 
roaming mode

Original comment by wim.stev...@gmail.com on 23 Mar 2012 at 7:52

GoogleCodeExporter commented 9 years ago
r2337 - thanks.

Original comment by T.Delenikas on 24 Mar 2012 at 10:46

GoogleCodeExporter commented 9 years ago

Original comment by T.Delenikas on 27 Mar 2012 at 5:30

GoogleCodeExporter commented 9 years ago

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