hack to store the smart beaconing log over time

smart_log
Georg Lukas 2011-05-26 12:24:51 +02:00
rodzic f5acfc8a8c
commit 163340e712
2 zmienionych plików z 12 dodań i 4 usunięć

Wyświetl plik

@ -12,6 +12,7 @@
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application android:label="@string/app_name" android:icon="@drawable/icon">
<uses-library android:name="com.google.android.maps" />

Wyświetl plik

@ -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