jvde-github / AIS-catcher-for-Android

Android AIS receiver for RTL SDR dongles, Airspy R2, Airspy Mini, Airspy HF+ and TCP (RTL-TCP and SpyServer). Output is send via UDP and visualized on the built-in map
GNU General Public License v3.0
98 stars 7 forks source link

AIS-catcher-for-Android stops receiving #6

Closed syspart closed 2 years ago

syspart commented 2 years ago

I have a no name rtl dongle. When I start I get 20 to 60 Messages, and than it stops. Even when I start the app again, or reattach the dongle, I only 0 to 2 new messages. With the same setting, dongle and antenna, with windows 10 and SDRangel I get a continous stream of NMEA messages Any idea what is wrong?

jvde-github commented 2 years ago

Hi! Thanks. I have not seen this before personally. Any information on the phone and Android version? In what state is the program if it stops (background)? And if it restarts do you see the "data received" counter still running?

The only thing I can think of is some battery optimization on the phone that does not grant the app the necessary running time after a while. I would play around a bit with the battery optimization settings for the app and see if that fixes it.

You could also try another RTL-SDR app and see if it shows the same problem? Then we can conclude it is the App and not the phone. For example, run https://play.google.com/store/apps/details?id=marto.rtl_tcp_andro. AIS-catcher can connect to this app to get the data from the dongle (via source = RTL-TCP driver).

syspart commented 2 years ago

The first device is a pixel 6 and android 13. Now I tested it with samsung galaxy s5 and lineageos android version 11. On lineage it starts with 25 messages. Than I deleted AIS-catcher restart the s5 installed ais-catcher reattach the dongle. And now I get 8 messages. Now I put the dongel in a freezer :-). And after 10 min back, I receive new messages. So its a temperature problem with the device. But as stated before, with SDRangel there is no problem with the temperature, the dongle is little warm, and it gets the messages.

syspart commented 2 years ago

So with the cooled device I get 240 messages. Data received counter is going on, but no more message are comming.

jvde-github commented 2 years ago

That freezer angle is funny. Thanks. So it is possible then that the heating of the device is causing some frequency drift that stops the app from properly receiving messages. If data is still coming in but nothing being picked up, that could be an explanation.

Does not explain why it is running so hot on Android. In principle SDRangel and AIS-catcher are both using libusb and the rtlsdr library. The logic should not be too different.

I did a run for >6 hours running the App reporting to MarineTraffic without the issues you seem to experience. Either Android implementation needs to be tweaked (I will do some testing as well with dongles comparing Windows and Android), or Android does not like this particular dongle for whatever reason or could it have to do with an OTG cable somehow?

syspart commented 2 years ago

On both systems the dongle dont get hot. Maybe hand warm.

jvde-github commented 2 years ago

Yes, sorry, you did not say that, only that it seems to be temperature related. Will see if I can replicate with a blue dongle but I would try if swapping the OTG cable resolves the issue.

syspart commented 2 years ago

The otg should not be the problem. They are different for pixel (usb-c) and micro-usb for the s5. I don't know how this hole stuff works, but when SDRangel uses a little different filter, which is not so vulnerable for a little frequency shift. But I am only guessing.

jvde-github commented 2 years ago

Ok, clear. If that is the case you would see a similar issue if you use AIS-catcher for Windows (https://github.com/jvde-github/AIS-catcher) which then should receive less messages than SDRangel on Windows. And then I think we can fix it (either by using a second algorithm embedded in AIS-catcher or introducing an extra setting making the App more forgiving on frequency drifts, the development version already has a switch -go CGF_WIDE on as experimental feature).

jvde-github commented 2 years ago

I think AIS-catcher allows +/- 4 ppm deviation in frequency before it starts to struggle which makes sense if there is no thermal drift as it gives a little bit of slack for the receiver and the sender.

The other way to test this hypothesis of thermal drift is to, once no more messages are detected but data is still streaming, stop the detection, go to settings and find a PPM settings that possibly works and start again (settings only become effective when reception is started).

syspart commented 2 years ago

There is a shift to ~ -10ppm. Sometimes -16ppm. It depends on how long it is running, or if I heat it up with my hand. But it was tricky, first I had to know, it could go downwards, and then testing it step by step. And after of lot of start and stops, the buttons at the bottom ditn't react any longer (Stop, clear, rtlsdr). But I could open the hamburger menu and go into settings. I had to clear app data and cache. Couldn't reproduce it, but it happened 2x.

jvde-github commented 2 years ago

Ok, great, thanks for testing! Then it is definitely thermal shift of this particular dongle then. I have added two new settings to the App and will upload soon (in an hour or tomorrow). Hopefully this gives some extra settings to overcome this issue.

jvde-github commented 2 years ago

Hello. I have created a new release with some extra options (https://github.com/jvde-github/AIS-catcher-for-Android/releases/tag/v0.21) and made this version also available in the Play store.

If you go to Settings there is now a Receiver section at the bottom with a setting named "Applied Frequency Correction". One thing you could try is to change this settings from Default -> Wide.

A second thing you could try (if that does not work) is to change the setting "Receiver Decoding Model" from Default to FM decoding. Had a look at the SDRangel code and it uses this method plus it corrects for DC offsets which AIS-catcher in this model does not do so this might not be the best solution against thermal drift. Not sure I have appetite to add it as it is not the default decoding model.

These models can better cope with frequency drift but are less sensitive and therefore might identify fewer messages (i.e. no free lunch). For other dongles which do not have this problem I would not advice to use these options.

Hope this works for you.

syspart commented 2 years ago

With applied frequency correction it is all fine. I get 450 messages with 120 MB. Thanks

jvde-github commented 2 years ago

Amazing, thanks for persevering to get to the bottom of this.

syspart commented 2 years ago

By the way, where do I get a openCPN map for the northsea. Download from https://alpha.openseamap.org/ did not work for me. And the kap map I found on wiki.openseamap.org have a terrible scale.

jvde-github commented 2 years ago

Don't know sorry,