X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosdroid%2Fsrc%2Forg%2Faltusmetrum%2FAltosDroid%2FTelemetryService.java;h=3cb498e8a1995c05ddc2edc954846016dfe83c79;hp=ffe96946772a114f92c770c1cfb768b09200244a;hb=3fe5c2f9fc01258d45c20070e9874d76bc6c8c07;hpb=6c985c2b0433a08add3bbf55fdb30102157b4ede diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java index ffe96946..3cb498e8 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java @@ -1,5 +1,5 @@ /* - * Copyright © 2012 Mike Beattie + * Copyright © 2012 Mike Beattie * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -52,6 +52,7 @@ public class TelemetryService extends Service { static final int MSG_CONNECT_FAILED = 5; static final int MSG_DISCONNECTED = 6; static final int MSG_TELEMETRY = 7; + static final int MSG_SETFREQUENCY = 8; public static final int STATE_NONE = 0; public static final int STATE_READY = 1; @@ -75,6 +76,7 @@ public class TelemetryService extends Service { private AltosBluetooth mAltosBluetooth = null; private AltosConfigData mConfigData = null; private TelemetryReader mTelemetryReader = null; + private TelemetryLogger mTelemetryLogger = null; // internally track state of bluetooth connection private int state = STATE_NONE; @@ -126,6 +128,15 @@ public class TelemetryService extends Service { case MSG_TELEMETRY: s.sendMessageToClients(Message.obtain(null, AltosDroid.MSG_TELEMETRY, msg.obj)); break; + case MSG_SETFREQUENCY: + if (s.state == STATE_CONNECTED) { + try { + s.mAltosBluetooth.set_radio_frequency((Double) msg.obj); + } catch (InterruptedException e) { + } catch (TimeoutException e) { + } + } + break; default: super.handleMessage(msg); } @@ -154,6 +165,11 @@ public class TelemetryService extends Service { } mTelemetryReader = null; } + if (mTelemetryLogger != null) { + if (D) Log.d(TAG, "stopAltosBluetooth(): stopping TelemetryLogger"); + mTelemetryLogger.stop(); + mTelemetryLogger = null; + } if (mAltosBluetooth != null) { if (D) Log.d(TAG, "stopAltosBluetooth(): stopping AltosBluetooth"); mAltosBluetooth.close(); @@ -206,6 +222,8 @@ public class TelemetryService extends Service { mTelemetryReader = new TelemetryReader(mAltosBluetooth, mHandler); mTelemetryReader.start(); + + mTelemetryLogger = new TelemetryLogger(this, mAltosBluetooth); }