@Override public void onGpsStatusChanged(final int event) { switch (event) { case GpsStatus.GPS_EVENT_FIRST_FIX: case GpsStatus.GPS_EVENT_SATELLITE_STATUS: { final GpsStatus status = geoManager.getGpsStatus(null); int visible = 0; int fixed = 0; for (final GpsSatellite satellite : status.getSatellites()) { if (satellite.usedInFix()) { fixed++; } visible++; } if (visible == latest.satellitesVisible && fixed == latest.satellitesFixed) { return; } latest = new Status(true, visible, fixed); break; } case GpsStatus.GPS_EVENT_STARTED: latest = new Status(true, 0, 0); break; case GpsStatus.GPS_EVENT_STOPPED: latest = new Status(false, 0, 0); break; default: throw new IllegalStateException(); } subscriber.onNext(latest); }
private void showSats() { int satNum = 0; StringBuilder builder = new StringBuilder(); for (GpsSatellite sat : gps.getSatellites()) { builder.append("Satellite Data: "); builder.append("\nnumber: "); builder.append(satNum); builder.append("\nAzimuth: "); builder.append(sat.getAzimuth()); builder.append("\nElevation: "); builder.append(sat.getElevation()); builder.append("\nSNR: "); builder.append(sat.getSnr()); builder.append("\nUsed in fix?: "); builder.append(sat.usedInFix()); log("\n\n" + builder.toString()); builder.delete(0, builder.length()); satNum++; } }
@Override public void onGpsStatusChanged(int event) { if (locationManager == null) return; android.location.GpsStatus gpsStatus = locationManager.getGpsStatus(null); if (gpsStatus == null) return; int cnt0 = 0, cnt1 = 0; Iterable<GpsSatellite> list = gpsStatus.getSatellites(); for (GpsSatellite satellite : list) { cnt0++; if (satellite.usedInFix()) { cnt1++; } } mKnownSatellites = cnt0; mUsedInLastFixSatellites = cnt1; if (listener != null) listener.onTick(); }
static String gpsToString(GpsStatus status, int eventType) { StringBuilder sb = new StringBuilder(); sb.append(eventType); sb.append("|ttff:"); sb.append(status.getTimeToFirstFix()); sb.append("|maxSatellites:"); sb.append(status.getMaxSatellites()); sb.append("|"); int i = 0; for (GpsSatellite sat : status.getSatellites()) { i++; sb.append("Satellite_"); sb.append(i); sb.append("::hasAlmanac:"); sb.append(sat.hasAlmanac()); sb.append("::hasEphemeris:"); sb.append(sat.hasEphemeris()); sb.append("::usedInFix:"); sb.append(sat.usedInFix()); sb.append("|"); } return sb.toString(); }
public void onGpsStatusChanged(int event) { switch (event) { case GpsStatus.GPS_EVENT_SATELLITE_STATUS: GpsStatus gpsStatus = mLocationManager.getGpsStatus(null); int satsInView = 0; int satsUsed = 0; Iterable<GpsSatellite> sats = gpsStatus.getSatellites(); for (GpsSatellite sat : sats) { satsInView++; if (sat.usedInFix()) { satsUsed++; } } satellite.setText(String.valueOf(satsUsed) + "/" + String.valueOf(satsInView)); if (satsUsed == 0) { fab.setImageDrawable(getResources().getDrawable(R.drawable.ic_action_play)); data.setRunning(false); status.setText(""); stopService(new Intent(getBaseContext(), GpsServices.class)); fab.setVisibility(View.INVISIBLE); refresh.setVisibility(View.INVISIBLE); accuracy.setText(""); status.setText(getResources().getString(R.string.waiting_for_fix)); firstfix = true; } break; case GpsStatus.GPS_EVENT_STOPPED: if (!mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { showGpsDisabledDialog(); } break; case GpsStatus.GPS_EVENT_FIRST_FIX: break; } }
/////// GPS status callback public void onGpsStatusChanged(int status) { DataOutputStream file = fout[2]; long tim = System.currentTimeMillis(); // Get the status GpsStatus lStatus = null; lStatus = mLocMan.getGpsStatus(null); if (status == GpsStatus.GPS_EVENT_FIRST_FIX) { mLV.addtext("GPS_EVENT_FIRST_FIX - TTFX =" + lStatus.getTimeToFirstFix()); } else if (status == GpsStatus.GPS_EVENT_STARTED) { mLV.addtext("GPS_EVENT_STARTED " + tim); } else if (status == GpsStatus.GPS_EVENT_STOPPED) { mLV.addtext("GPS_EVENT_STOPPED " + tim); } if (lStatus != null) { if (file != null) { try { file.writeLong(tim); Iterable<GpsSatellite> satlist = lStatus.getSatellites(); for (GpsSatellite sat : satlist) { file.writeInt(sat.getPrn()); file.writeFloat(sat.getAzimuth()); file.writeFloat(sat.getElevation()); file.writeFloat(sat.getSnr()); file.writeBoolean(sat.hasAlmanac()); file.writeBoolean(sat.hasEphemeris()); file.writeBoolean(sat.usedInFix()); if (satlist.iterator().hasNext()) file.writeChar('@'); else file.writeChar('#'); } } catch (IOException e) { e.printStackTrace(); } } } }
public void onGpsStatusChanged(int state) { GpsStatus gpsStatus = locationManager.getGpsStatus(null); if (state == GpsStatus.GPS_EVENT_STOPPED) { hasFix = false; numSatellites = 0; updateSolution(LocationProvider.OUT_OF_SERVICE); } else if ((System.currentTimeMillis() - lastFixTimestamp) > 3000) { invalidateFix(); } if (state == GpsStatus.GPS_EVENT_STARTED) { // FIXME do what's needed updateSolution(LocationProvider.AVAILABLE); } gpsState = state; if (state == GpsStatus.GPS_EVENT_SATELLITE_STATUS && gpsStatus != null) { for (int j = 0; j < 36; j++) { /** Resetting all the satellites to non locked */ if ((satellites[j] != null)) { satellites[j].isLocked(false); } } Iterable<GpsSatellite> andSatellites = gpsStatus.getSatellites(); Iterator<GpsSatellite> sat = andSatellites.iterator(); int i = 0; while (sat.hasNext()) { GpsSatellite satellite = sat.next(); if (satellites[i] == null) { satellites[i] = new Satellite(); } if (i < 36) { satellites[i].isLocked(satellite.usedInFix()); satellites[i].id = i; satellites[i].azimut = satellite.getAzimuth(); satellites[i].elev = satellite.getElevation(); satellites[i].snr = (int) satellite.getSnr(); if (satellite.usedInFix()) { i++; } } } numSatellites = i; if (numSatellites > 0) { receiverList.receiveSatellites(satellites); } } // updateSolution(state); }