From 163340e7125cdef364c615cf2df2a46577b3c295 Mon Sep 17 00:00:00 2001 From: Georg Lukas Date: Thu, 26 May 2011 12:24:51 +0200 Subject: [PATCH] hack to store the smart beaconing log over time --- AndroidManifest.xml | 1 + src/AprsService.scala | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 55547eb..b92867a 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -12,6 +12,7 @@ + diff --git a/src/AprsService.scala b/src/AprsService.scala index ba017e4..5fa2c7e 100644 --- a/src/AprsService.scala +++ b/src/AprsService.scala @@ -207,6 +207,15 @@ class AprsService extends Service with LocationListener { ((SB_SLOW_RATE - SB_FAST_RATE) * (SB_FAST_SPEED - speed) / (SB_FAST_SPEED-SB_SLOW_SPEED)).toInt } + def LogF(s : String) { + import java.io._ + val path = android.os.Environment.getExternalStorageDirectory() + Log.d(TAG, s) + val f = new FileWriter(new File(path, "aprsdroid.log"), true) + f.write("%s\n".format(s)) + f.close() + } + // returns the angle between two bearings def getBearingAngle(alpha : Float, beta : Float) : Float = { val delta = math.abs(alpha-beta)%360 @@ -230,7 +239,7 @@ class AprsService extends Service with LocationListener { // threshold depends on slope/speed [mph] val threshold = SB_TURN_MIN + SB_TURN_SLOPE/(getSpeed(location)*2.23693629) - Log.d(TAG, "smartBeaconCornerPeg: %1.0f < %1.0f %d/%d".format(turn, threshold, + LogF("smartBeaconCornerPeg: %1.0f < %1.0f %d/%d".format(turn, threshold, t_diff/1000, SB_TURN_TIME)) // need to corner peg if turn time reached and turn > threshold (t_diff/1000 >= SB_TURN_TIME && turn > threshold) @@ -247,7 +256,7 @@ class AprsService extends Service with LocationListener { val speed = getSpeed(location) //if (location.hasSpeed && location.hasBearing) val speed_rate = smartBeaconSpeedRate(speed) - Log.d(TAG, "smartBeaconCheck: %1.0fm, %1.2fm/s -> %d/%ds - %s".format(dist, speed, + LogF("smartBeaconCheck: %1.0fm, %1.2fm/s -> %d/%ds - %s".format(dist, speed, t_diff/1000, speed_rate, (t_diff/1000 >= speed_rate).toString)) if (t_diff/1000 >= speed_rate) true @@ -259,8 +268,6 @@ class AprsService extends Service with LocationListener { override def onLocationChanged(location : Location) { val upd_int = prefs.getStringInt("interval", 10) * 60000 val upd_dist = prefs.getStringInt("distance", 10) * 1000 - //Log.d(TAG, "onLocationChanged: n=" + location) - //Log.d(TAG, "onLocationChanged: l=" + lastLoc) if (/* smart beaconing == */ true) { if (!smartBeaconCheck(location)) return