1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

AndroidGCS: Add a toast message when connected (all objects downloaded)

This commit is contained in:
James Cotton 2012-08-13 01:37:15 -05:00
parent 53d4d8b507
commit f96b419a85
3 changed files with 16 additions and 4 deletions

View File

@ -112,7 +112,7 @@ public class HidUAVTalk extends TelemetryTask {
telemService.registerReceiver(usbPermissionReceiver, permissionFilter);
deviceAttachedFilter = new IntentFilter();
//deviceAttachedFilter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
deviceAttachedFilter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
deviceAttachedFilter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
telemService.registerReceiver(usbReceiver, deviceAttachedFilter);
@ -200,8 +200,8 @@ public class HidUAVTalk extends TelemetryTask {
{
if (device.equals(currentDevice))
{
telemService.toastMessage("Device unplugged while in use");
if (DEBUG) Log.d(TAG, "Matching device disconnected");
// call your method that cleans up and closes communication with the device
disconnect();
}
@ -348,6 +348,8 @@ public class HidUAVTalk extends TelemetryTask {
}, "HID Write");
writeThread.start();
telemService.toastMessage("HID Device Opened");
return true;
}

View File

@ -106,7 +106,7 @@ public abstract class TelemetryTask implements Runnable {
// data stream
uavTalk = new UAVTalk(inStream, outStream, objMngr);
tel = new Telemetry(uavTalk, objMngr);
mon = new TelemetryMonitor(objMngr,tel);
mon = new TelemetryMonitor(objMngr,tel, telemService);
// Create an observer to notify system of connection
mon.addObserver(connectionObserver);

View File

@ -34,6 +34,8 @@ import java.util.Observer;
import java.util.Timer;
import java.util.TimerTask;
import org.openpilot.androidgcs.telemetry.OPTelemetryService;
import android.util.Log;
public class TelemetryMonitor extends Observable {
@ -60,6 +62,7 @@ public class TelemetryMonitor extends Observable {
private long lastUpdateTime;
private final List<UAVObject> queue;
private OPTelemetryService telemService;
private boolean connected = false;
private boolean objects_updated = false;
@ -71,6 +74,11 @@ public class TelemetryMonitor extends Observable {
return objects_updated;
};
public TelemetryMonitor(UAVObjectManager objMngr, Telemetry tel, OPTelemetryService s) {
this(objMngr, tel);
telemService = s;
}
public TelemetryMonitor(UAVObjectManager objMngr, Telemetry tel) {
this.objMngr = objMngr;
this.tel = tel;
@ -171,7 +179,9 @@ public class TelemetryMonitor extends Observable {
public synchronized void retrieveNextObject() throws IOException {
// If queue is empty return
if (queue.isEmpty()) {
if (DEBUG || true) Log.d(TAG, "All objects retrieved: Connected Successfully");
if (telemService != null)
telemService.toastMessage("Connected");
if (DEBUG) Log.d(TAG, "All objects retrieved: Connected Successfully");
objects_updated = true;
if (!HANDSHAKE_IS_CONNECTED) {
setChanged();