TrueWatcher / tower

Navigation tool for Android
12 stars 0 forks source link

wishlist: track cell tower signal strength on map #5

Closed hackerb9 closed 8 months ago

hackerb9 commented 10 months ago

It would be nice if the map could indicate the cell tower signal strength (RSRP) detected at each location. I'm imagining that it would adjust the track opacity: a signal strength less than -100dBm would be clear and -50dBm would be 50% translucent. (Not fully opaque since I'd want to see the map beneath).

Even more useful would be if the color changed depending upon which cell tower I'm connected to, but I don't know if Tower has access to that information. If multiple towers are in range, it could be a blending of colors.

Thanks!

TrueWatcher commented 10 months ago

hackerb9 , thanks for your interest :)

The easiest thing to do is to add RSRP to the cell data (MCC, MNC, LAC, CID), it seems to be available for LTE via CellInfoLte::getCellSignalStrength().getDbm() . There seems to be a similar method for 5G in CellInfoNr , but unfortunately there are no 5G networks in my country :(( so I can add the 5G capabilities, but cannot test them myself.

Another thing is to store the RSRP in the waypoint/trackpoint. The RSRP is meaningful only with the cell ID, but the device chooses the cell by itself and well may connect to different cells from adjacent ttrackpoints. Currently I have no idea how to organize this data.

Visualisation is still another thing. To add opacity to tracks (or color shades, or anything more than flat base color) will require rewriting the Javascript library (leafletjs) and the adapter layers, so it's not a one-time job.

Any further ideas are welcome. I will also think a little more on these.

hackerb9 commented 10 months ago

If you add the 5G features, I will gladly test them for you.

I don't know if this makes it any easier, but I read that leaflet lets developers overlay SVG, which can draw with opacity.

TrueWatcher commented 10 months ago

OK, I'll add RSRP querying for 4G and 5G cells as soon as I get to my 64-bit machine (hopefully in 1-2 weeks).

With leaflet, the problem is -- how to involve extra data (signal strength and some indication of a cell handover) into the process of drawing a track, that in case of L.Polyline consumes only coordinates. I've found a plugin that does that: https://github.com/Oliv/leaflet-polycolor , but currently I have some problems with their code: https://github.com/Oliv/leaflet-polycolor/issues/16 , https://github.com/Oliv/leaflet-polycolor/issues/19

By the way, opacity does not seem great to me. I'm sure that no one can notice a 5% opacity line over any map details, and it's also difficult to tell 20% from 40%. I'm voting for a linear color scale from dark red to orange; we'll need to do some experimentation on real cells and real maps.

If you need to see the map clearly, there's a button Hide/Show in the top right corner screenshot 1.

TrueWatcher commented 9 months ago

OK, the new version is ready. It must show RSRP/dBm and other cell params for all networks, including 5G/NR

If you add the 5G features, I will gladly test them for you.

Yes, that will be kind of you :) get APK from the project site sha256 04ff680de18213196d1383c2e96fa1ad024392fcbac2f629717f4a2168eb696f

It's very interesting also if it can get cell locations for the 5G kind. There are two services (Settings - cell location service), both may be problematic :(

hackerb9 commented 9 months ago

First it was crashing when I click on Cell. The first time it asked for permissions before crashing, after that it simply crashed immediately.

``` type: crash osVersion: google/raven/raven:14/UP1A.231105.003/2023111500:user/release-keys package: truewatcher.tower:70 process: truewatcher.tower processUptime: 3815 + 198 ms installer: com.android.packageinstaller truewatcher.tower.g0$e: Not allowed to access cell info at truewatcher.tower.b.g(Unknown Source:118) at truewatcher.tower.b.a(Unknown Source:0) at truewatcher.tower.w.a(Unknown Source:55) at truewatcher.tower.MainActivity$a.b(Unknown Source:14) at android.support.v4.app.f.d(Unknown Source:13) at android.support.v4.app.l.b(Unknown Source:26) at android.support.v4.app.i.b(Unknown Source:4) at android.support.v4.app.g.onMenuItemSelected(Unknown Source:24) at android.support.v7.app.d.onMenuItemSelected(Unknown Source:0) at a.b.d.g.i.onMenuItemSelected(Unknown Source:2) at android.support.v7.app.g.a(Unknown Source:22) at android.support.v7.view.menu.h.a(Unknown Source:4) at android.support.v7.view.menu.k.g(Unknown Source:14) at android.support.v7.view.menu.h.a(Unknown Source:12) at android.support.v7.view.menu.h.a(Unknown Source:1) at android.support.v7.widget.ActionMenuView.a(Unknown Source:3) at android.support.v7.view.menu.ActionMenuItemView.onClick(Unknown Source:6) at android.view.View.performClick(View.java:7659) at android.view.View.performClickInternal(View.java:7636) at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0) at android.view.View$PerformClick.run(View.java:30156) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294) at android.app.ActivityThread.main(ActivityThread.java:8199) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) at com.android.internal.os.ExecInit.main(ExecInit.java:49) at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:359) ```

However, if I click on GPS first, it asks for location permission and after that pressing Cell doesn't cause a crash. Unfortunately, it gives a Resolver failure, 404 error by default.

Screenshot_20231119-193501

Turning Cell Location Service off instead of using mylnikov.org got around that issue.

Screenshot_20231119-194616

Changing the settings to use Yandex Locator also works, but with very bad map accuracy, plus or minus 100km. (Which is fine by me as I'd prefer to not use Yandex if I can l help it after what the founder, Arkady Volozh, revealed a couple months ago.)

hackerb9 commented 9 months ago

I notice the signal strength (-91dBm) doesn't match what I'm getting from settings -> about phone -> sim status, which says "-77 dBm 63 asu".

Trying it in a different location, I'm able to get Tower to show an improved signal, -84 dBm, but the SIM status shows much worse, -92 dBm. In both cases the connection is 5G NR SA.

I'm not sure, but perhaps this is the difference between RSSI and RSRP (which should be more accurate, but was not available before 4G LTE).

If RSSI, RSRP, and RSRQ were all printed out with their names. it might make the situation more clear.

You probably know all this, but here's a website which helped me understand RSSI, RSRP, and RSRQ: https://5gstore.com/blog/2021/04/08/understanding-rssi-rsrp-and-rsrq/

TrueWatcher commented 9 months ago

hackerb9, thank you very much ! So, the app now basically gets the data for 5G cells, that's a good news.

Crashing on first run will be dealt with.

Error 404 from mylnikov.org is not an issue, it just means they got no data on this cell. The issue with mylnikov.org is that they may give a 15km miss or are offline altogether. The 100km accuracy from YandexLocator means they also have no cell data and resolve your IP instead. In my country Yandex works so well that it makes me afraid (200m and less with single LTE cell), but that must very much depend on the country.

Should I set None as the default service?

TrueWatcher commented 9 months ago

The app code now uses CellSignalStrengthNr.getDbm() that should produce "the SS-RSRP as dBm value -140..-44dBm or UNAVAILABLE"

There are also getCsiRsrp() and getSsRsrp() by 3GPP TS 38.133 10.1.6.1. on the same object. I can add any of them if that helps.

For LTE it's getDbm() now, but there's also [getRsrp](https://developer.android.com/reference/android/telephony/CellSignalStrengthLte#getRsrp())() that""Gets reference signal received power in dBm Range: -140 dBm to -43 dBm."

hackerb9 commented 9 months ago

hackerb9, thank you very much ! So, the app now basically gets the data for 5G cells, that's a good news.

Hooray!

Should I set None as the default service?

I don't know if people would find that useful. Maybe if it showed a message showing the raw cell data and said, "To convert cell tower id to location, please select one of the following providers..."

Another idea is to default to Mozilla's open source database which seems to cover a complementary set of cell towers: https://location.services.mozilla.com/

mozilla map coverage

MLS can also determine your location by WiFi and Bluetooth for better precision in urban environments, but it's not required.

https://OpenCellID.org may be another good data source.

Both projects get their data from volunteers who upload data using an app like Tower Collector.

hackerb9 commented 9 months ago

There are also getCsiRsrp() and getSsRsrp() by 3GPP TS 38.133 10.1.6.1. on the same object. I can add any of them if that helps.

Hm. I don't know the difference between SS-RSRP and CSI-RSRP. If you wouldn't mind adding in that and the other readings, I'd appreciate it. Oh and the SINR and RSRQ might be interesting to see how much interference there is.

hackerb9 commented 9 months ago

Googling around, I found a table of the relevant metrics for 5G NR based on 38.215 - 5.1 UE measurement capabilities

Category Physical Signal for Measurement
RSRP SS reference signal received power (SS-RSRP)
CSI reference signal received power (CSI-RSRP)
SRS reference signal received power (SRS-RSRP)
RSRQ SS reference signal received quality (SS-RSRQ)
CSI reference signal received quality (CSI-RSRQ)
SINR SS signal-to-noise and interference ratio (SS-SINR)
CSI signal-to-noise and interference ratio (CSI-SINR)
RSSI
TrueWatcher commented 9 months ago

to default to Mozilla's open source database

I was considering that. Both Mozilla and OpenCellID require their access code (that makes F-droid downmark your app for "promoting non-free services") and will give it to a developer only if the app sends them users\' precise 'locations to feed their database. Mylnikov.org claims he has all data from Mozilla, OpenCellID "and many others" and at least is as free as sea.

The next version is very near :)

hackerb9, would you perfom a new small test: 1) make your device reconnect to another cell (e.g Settings - More - Cellular networks - preferred type - 3G) 2) immediately check in the app if it shows the new cell data (I have just read that since Android 10 some phones require very different function call to get cell info, and,, worse, give stall data to getAllCellInfo() )

TrueWatcher commented 9 months ago

I've just found a great technical menu. It's called up by dialing *#*#4636#*#* Unlike settings -> about phone -> sim status, it displays RSRP, RSRQ and CID for all visible cells ! In my case, with LTE the displayed RSRP was equal to Tower's dBm

TrueWatcher commented 9 months ago

// Version 2.9.4 is ready. // /t should not crash on first run. Version 2.9.5: APK at the project site 1.8 MB, SHA256: b35bf62f0db316d26a6ae2f48ba3aee8003798c4c75c1c41fe42955a30374acc Tested in an emulator with API 34, and in live devices with Android 10 and 7.0.

It should display plenty of data for the 5G cells, nearly all kinds mentioned in CellSignaStrengthNr reference

It also displays cellInfo metadata "age" and "primary". Age is expected to be somewhere between 0 and 10 seconds, primary must be 1.

TrueWatcher commented 9 months ago

The show is going on:

Write track with cell and signal data to a local csv file: https://github.com/TrueWatcher/tower/tree/signaltrackwriter

get APK 1.4 MB, SHA256 c4bccbaf0c65dcf2d80a4d323f4593f29f3abd681549ba41d92da248bb38a413

.

Visualiser in html+javascript: https://github.com/TrueWatcher/tower/tree/webmapviewer_exp

open online