Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart TX #1

Open
valentintintin opened this issue Mar 9, 2019 · 4 comments
Open

Smart TX #1

valentintintin opened this issue Mar 9, 2019 · 4 comments

Comments

@valentintintin
Copy link
Owner

Speed ? Difference between last pos ? Time ?

@valentintintin
Copy link
Owner Author

aaff00e + a93ab56

@valentintintin
Copy link
Owner Author

valentintintin commented Aug 20, 2019

Use time between tx conditioned by speed, angle etc

Idea : https://github.com/N7ILK/DRA818V_Tracker/blob/master/DRA818V_APRS.ino

@valentintintin
Copy link
Owner Author

Code from APRSDroid :

/*
 * Decompiled with CFR 0.0.
 * 
 * Could not load the following classes:
 *  android.content.Context
 *  android.location.Location
 *  android.location.LocationListener
 *  android.location.LocationManager
 *  android.os.Bundle
 *  android.util.Log
 *  android.widget.Toast
 *  java.lang.Boolean
 *  java.lang.Float
 *  java.lang.IllegalArgumentException
 *  java.lang.Object
 *  java.lang.String
 *  scala.math.package$
 */
package org.aprsdroid.app;

import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import org.aprsdroid.app.AprsService;
import org.aprsdroid.app.LocationSource;
import org.aprsdroid.app.PrefsWrapper;
import scala.Predef$;
import scala.collection.Seq;
import scala.collection.immutable.StringOps;
import scala.collection.mutable.StringBuilder;
import scala.math.package$;

public final class SmartBeaconing
extends LocationSource
implements LocationListener {
    private final String TAG;
    private volatile boolean bitmap$0;
    private Location lastLoc;
    private LocationManager locMan;
    private final PrefsWrapper prefs;
    private final AprsService service;
    private boolean started;

    public SmartBeaconing(AprsService aprsService, PrefsWrapper prefsWrapper) {
        this.service = aprsService;
        this.prefs = prefsWrapper;
        this.TAG = "APRSdroid.SmartBeaconing";
        this.lastLoc = null;
        this.started = false;
    }

    private LocationManager locMan() {
        if (this.bitmap$0) {
            return this.locMan;
        }
        return this.locMan$lzycompute();
    }

    private LocationManager locMan$lzycompute() {
        SmartBeaconing smartBeaconing = this;
        synchronized (smartBeaconing) {
            if (!this.bitmap$0) {
                this.locMan = (LocationManager)this.service.getSystemService("location");
                this.bitmap$0 = true;
            }
            return this.locMan;
        }
    }

    /*
     * Enabled aggressive block sorting
     */
    public final void onLocationChanged(Location location) {
        boolean bl;
        if (this.lastLoc == null) {
            bl = true;
        } else {
            boolean bl2;
            float f;
            int n = this.prefs.getStringInt("sb.turntime", 15);
            int n2 = this.prefs.getStringInt("sb.turnmin", 10);
            double d = 1.0 * (double)this.prefs.getStringInt("sb.turnslope", 240);
            float f2 = location.getSpeed();
            long l = location.getTime() - this.lastLoc.getTime();
            float f3 = location.getBearing();
            float f4 = package$.abs((float)(f3 - (f = this.lastLoc.getBearing()))) % 360.0f;
            if (!(f4 <= 180.0f)) {
                f4 = 360.0f - f4;
            }
            if (location.hasBearing() && f2 != 0.0f) {
                if (this.lastLoc.hasBearing()) {
                    double d2 = (double)n2 + d / (2.23693629 * (double)f2);
                    String string = this.TAG;
                    StringOps stringOps = new StringOps(Predef$.augmentString("smartBeaconCornerPeg: %1.0f < %1.0f %d/%d"));
                    Object[] arrobject = new Object[]{Float.valueOf((float)f4), d2, l / 1000L, n};
                    Log.d((String)string, (String)stringOps.format(Predef$.genericWrapArray(arrobject)));
                    bl2 = l / 1000L >= (long)n && (double)f4 > d2;
                } else {
                    bl2 = l / 1000L >= (long)n;
                }
            } else {
                bl2 = false;
            }
            if (bl2) {
                bl = true;
            } else {
                float f5 = location.distanceTo(this.lastLoc);
                long l2 = location.getTime() - this.lastLoc.getTime();
                float f6 = location.distanceTo(this.lastLoc);
                long l3 = location.getTime() - this.lastLoc.getTime();
                float f7 = package$.max((float)package$.max((float)(f6 * 1000.0f / (float)l3), (float)location.getSpeed()), (float)this.lastLoc.getSpeed());
                double d3 = (double)this.prefs.getStringInt("sb.fastspeed", 100) / 3.6;
                int n3 = this.prefs.getStringInt("sb.fastrate", 60);
                double d4 = (double)this.prefs.getStringInt("sb.slowspeed", 5) / 3.6;
                int n4 = this.prefs.getStringInt("sb.slowrate", 1200);
                if (!((double)f7 <= d4)) {
                    n4 = (double)f7 >= d3 ? n3 : (int)((double)n3 + (double)(n4 - n3) * (d3 - (double)f7) / (d3 - d4));
                }
                String string = this.TAG;
                StringOps stringOps = new StringOps(Predef$.augmentString("smartBeaconCheck: %1.0fm, %1.2fm/s -> %d/%ds - %s"));
                Object[] arrobject = new Object[5];
                arrobject[0] = Float.valueOf((float)f5);
                arrobject[1] = Float.valueOf((float)f7);
                arrobject[2] = l2 / 1000L;
                arrobject[3] = n4;
                boolean bl3 = l2 / 1000L >= (long)n4;
                arrobject[4] = Boolean.valueOf((boolean)bl3).toString();
                Log.d((String)string, (String)stringOps.format(Predef$.genericWrapArray(arrobject)));
                if (l2 / 1000L < (long)n4) return;
                bl = true;
            }
        }
        if (!bl) return;
        this.lastLoc = location;
        this.service.postLocation(location);
    }

    /*
     * Enabled aggressive block sorting
     */
    public final void onProviderDisabled(String string) {
        Log.d((String)this.TAG, (String)new StringBuilder().append((Object)"onProviderDisabled: ").append((Object)string).toString());
        if (string == null || !string.equals((Object)"gps")) {
            return;
        }
        Toast.makeText((Context)this.service, (int)2131099697, (int)1).show();
    }

    public final void onProviderEnabled(String string) {
        Log.d((String)this.TAG, (String)new StringBuilder().append((Object)"onProviderEnabled: ").append((Object)string).toString());
    }

    public final void onStatusChanged(String string, int n, Bundle bundle) {
        Log.d((String)this.TAG, (String)new StringBuilder().append((Object)"onStatusChanged: ").append((Object)string).toString());
    }

    /*
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     */
    @Override
    public final String start(boolean bl) {
        this.lastLoc = null;
        if (this.started) return this.service.getString(2131099788);
        try {
            this.locMan().requestLocationUpdates("gps", 0L, 0.0f, (LocationListener)this);
            this.started = true;
        }
        catch (IllegalArgumentException illegalArgumentException) {
            this.service.postAbort(new StringBuilder().append((Object)this.service.getString(2131099697)).append((Object)"\n").append((Object)illegalArgumentException.getMessage()).toString());
            return this.service.getString(2131099788);
        }
        return this.service.getString(2131099788);
    }

    @Override
    public final void stop() {
        if (this.started) {
            this.locMan().removeUpdates((LocationListener)this);
        }
        this.started = false;
    }
}

@valentintintin
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant