`GPGGA` and `GPRMC` sentences are not received in onNmeaMessage
Asked Answered
C

0

2

The Problem

I am working on the application which is listening for NMEA messages, to do so I am adding NMEA listener like this

locationManager.requestLocationUpdates(
    LocationManager.GPS_PROVIDER,
    TimeUnit.SECONDS.toMillis(1L),
    0.0f, 
    new LocationListener() { /* Some code goes here*/ }
);

// πŸ‘‡ Adding NMEA LISTENER πŸ‘‡
locationManager.addNmeaListener(new OnNmeaMessageListener() {

    @Override
    public void onNmeaMessage(String nmea, long timestampMs) {
        Log.d(TAG, "NMEA Message Received [" + timestampMs + "]: " + nmea);
    }

}, new Handler(Looper.getMainLooper()));

I am only interested in the 2 types of NMEA sentences:

  • GPGGA - Global Positioning System Fix Data
  • GPRMC - Recommended minimum specific GPS/Transit data

but the issue is that when I am in the room (without or with bad GPS signal) I am receiving data like

$GPGGA,,,,,,0,,,,,,,,*66
$GPRMC,,V,,,,,,,,,,N,V*29

and when I am going outside (so GPS signal is strong), the method onNmeaMessage stops receiving GPGGA and GPRMC sentences at all, it receives a lot of other sentences but not that two.

Question

  • Who can explain or give me a hint why with bad GPS signal I am receiving garbage date and with a strong GPS signal I am not receiving GPGGA and GPRMC sentences at all?

  • What should I do to constantly start listening for GPGGA and GPRMC sentences?

Device

  • Pixel 3a XL
  • Android 10
  • With WiFI connected and 4G

Sourcecode

https://gist.github.com/ChamichApps/c0c85c5ccc87f159c7e1676dbe0d02ff

Notes

Interestingly that same source code is running on Samsung S10+ and I can see the GPGGA and GPRMC logs.

Cerf answered 16/9, 2020 at 10:8 Comment(4)
@CommonsWare maybe you can help – Cerf
Those blank GPGGA and GPRMC sentences aren't garbage data... they're what you should expect if there isn't enough data for a fix. As for why you stop receiving them later though, I'm not sure. It's possible that the internal GPS/GNSS unit doesn't actually use NMEA and that these messages are emulated. – Operculum
Thanks, @Brad, yes that what I also assume about "garbage data", but still I can't understand why on Samsung S11+ I am getting these messages on Pixel I am not getting these messages, or even if I am getting it's only 2 times? How I can fix this? and when this data should come? if it's from the GPS chip can I control it? or I am just receiver and have no impact on it, expect standing under the blue sky? – Cerf
I assume you application has requested ACCESS_FINE_LOCATION in the manifest and dynamically in the application. – Berns

© 2022 - 2024 β€” McMap. All rights reserved.