Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Range for signalStrength in dbm for CDMA devices

I am checking Signal Strength for CDMA devices. Can anyone specify the range signalStrength.getCdmaDbm() returns?. Lowest is -120 but for full signal strength what is the value? Highest I got is -52.

like image 674
JAPS Avatar asked Feb 27 '12 11:02

JAPS


1 Answers

Well I am not sure if this is what you are looking for but after taking a look at the SignalStrength.java file in android source I noticed a bit of code that has a bunch of levels for cdma dbm and ecio levels.

DBM 
level 4 >= -75
level 3 >= -85
level 2 >= -95
level 1 >= -100

Ecio 
level 4 >= -90
level 3 >= -110
level 2 >= -130
level 1 >= -150

and level is the lowest of the two

actualLevel = (levelDbm < levelEcio) ? levelDbm : levelEcio;

but I noticed that this does not correlate to the actual bars showing in the notification. If in 3G then this level is ignored and the Signal to Noise ratio is used.

signalStrength.getEvdoSnr() // value is 0 to 8 so divide by two to get the bars

if the data drops from 3G to 1x then use the actualLevel.

This was my code to find show the number of bars .

   public void onSignalStrengthsChanged(SignalStrength signalStrength) {
        super.onSignalStrengthsChanged(signalStrength);
        if (signalStrength.isGsm()) {
            if (signalStrength.getGsmSignalStrength() != 99)
                signalStrengthValue = signalStrength.getGsmSignalStrength() * 2 - 113;
            else
                signalStrengthValue = signalStrength.getGsmSignalStrength();
        } else {
            final int snr = signalStrength.getEvdoSnr();
            final int cdmaDbm = signalStrength.getCdmaDbm();
            final int cdmaEcio = signalStrength.getCdmaEcio();
            int levelDbm;
            int levelEcio;
            int level = 0;

            if (snr == -1) {
                if (cdmaDbm >= -75) levelDbm = 4;
                else if (cdmaDbm >= -85) levelDbm = 3;
                else if (cdmaDbm >= -95) levelDbm = 2;
                else if (cdmaDbm >= -100) levelDbm = 1;
                else levelDbm = 0;

                // Ec/Io are in dB*10
                if (cdmaEcio >= -90) levelEcio = 4;
                else if (cdmaEcio >= -110) levelEcio = 3;
                else if (cdmaEcio >= -130) levelEcio = 2;
                else if (cdmaEcio >= -150) levelEcio = 1;
                else levelEcio = 0;

                level = (levelDbm < levelEcio) ? levelDbm : levelEcio;
            } else {
                if (snr == 7 || snr == 8) level =4;
                else if (snr == 5 || snr == 6 ) level =3;
                else if (snr == 3 || snr == 4) level = 2;
                else if (snr ==1 || snr ==2) level =1;

            }

            text.setText("Bars= " + level);


        }
    }

in the on create method use this below, and also make sure manifest uses READ_PHONE_STATE.

    TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
    AndroidPhoneStateListener phoneStateListener = new AndroidPhoneStateListener(text);
    telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
like image 76
JPM Avatar answered Oct 22 '22 23:10

JPM