Android pulling LTE RSRP value

855 Views Asked by At

First, here's my code for getting lte rsrp (or other) values. This code piece runs on another aysncTask.

 TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        int tempInt;
        while (isRunning) {
            try {
                List<CellInfo> cellInfoList = tm.getAllCellInfo();

                if (cellInfoList != null && cellInfoList.size() != 0) {
                        msg = handler.obtainMessage();
                        CellInfo cellInfo = cellInfoList.get(0);
                        result = -9999;
                        tempInt = 0;
                        if (cellInfo instanceof CellInfoWcdma) {
                            result = ((CellInfoWcdma) cellInfo).getCellSignalStrength().getDbm();
                            Log.e(TAG, "3G : " + result + "");
                        } else if (cellInfo instanceof CellInfoLte) {
                            result = ((CellInfoLte) cellInfo).getCellSignalStrength().getDbm();
                            Log.e(TAG, "LTE : " + result);
                        } else if (cellInfo instanceof CellInfoGsm) {
                            result = ((CellInfoGsm) cellInfo).getCellSignalStrength().getDbm();
                            Log.e(TAG, "GSM" + result);
                        } else if (cellInfo instanceof CellInfoCdma) {
                            result = ((CellInfoCdma) cellInfo).getCellSignalStrength().getDbm();
                            Log.e(TAG, "CDMA" + result);
                        }
.....

The problem is, I am not sure the data I'm getting is correct.

While I make this source run on background to see the rsrp value, I run the hidden menu of my LG G3 using the command *123456#. It shows a debug mode showing the realtime rsrp value.

The issue is, the rsrp I'm getting on my app's log and the one on the hidden menu is different in most cases. My app shows about -3 ~ +3 more.

Why is this happenning? Is there something wrong with my code? The above code has no time intervals and will continue before I force close the application.

1

There are 1 best solutions below

0
On

Nothing wrong with your code. If you check the 3GPP Standards documents, you will see that device manufacturers are given some room when reporting RSRP, a spread of 16 dB, that is, they must be within +/-8dB. The fact that you are still within that range tells me your code is probably fine. Also, running the secret code at the same time as your app can give you conflicting readings. What you should really do is find one place where you get a consistent RSRP reading using the phones secret code (be sure to turn off your LTE and Wifi, if these are on you will get interference. I know it's counter-intuitive to turn your LTE off if you are trying to get your LTE RSRP, but that's how it was designed.). Once you get a good reading, turn your LTE back on, but keep Wifi off (it can still interfere) and open your app to get the RSRP reading from there. If your apps RSRP is within +/-8dB of the RSRP reported from the phones field mode, then you are good.

For your info, here is an android app that I made which grabs RSRP among other LTE parameters: https://github.com/parksjg/IndoorLTE3a