ICP3 working
[fw/altos] / altosui / AltosIdleMonitorUI.java
index 2ee909374a313d50492dd3e2ffb42e167696218a..ce608d2b3bc6480e0717e318047e3df0a98868d4 100644 (file)
@@ -84,6 +84,7 @@ class AltosADC {
                                        i += 2;
                                        continue;
                                }
+                               i++;
                        }
                        break;
                }
@@ -178,8 +179,23 @@ class AltosIdleMonitor extends Thread {
        AltosADC                adc;
        AltosGPS                gps;
 
+       int AltosRSSI() throws TimeoutException, InterruptedException {
+               serial.printf("s\n");
+               String line = serial.get_reply_no_dialog(5000);
+               if (line == null)
+                       throw new TimeoutException();
+               String[] items = line.split("\\s+");
+               if (items.length < 2)
+                       return 0;
+               if (!items[0].equals("RSSI:"))
+                       return 0;
+               int rssi = Integer.parseInt(items[1]);
+               return rssi;
+       }
+
        void update_state() throws InterruptedException, TimeoutException {
-               AltosRecord     record = new AltosRecord();
+               AltosRecordTM   record = new AltosRecordTM();
+               int             rssi;
 
                try {
                        if (remote) {
@@ -191,19 +207,23 @@ class AltosIdleMonitor extends Thread {
                        adc = new AltosADC(serial);
                        gps = new AltosGPSQuery(serial, config_data);
                } finally {
-                       if (remote)
+                       if (remote) {
                                serial.stop_remote();
+                               rssi = AltosRSSI();
+                       } else
+                               rssi = 0;
                }
 
                record.version = 0;
                record.callsign = config_data.callsign;
                record.serial = config_data.serial;
                record.flight = config_data.log_available() > 0 ? 255 : 0;
-               record.rssi = 0;
+               record.rssi = rssi;
                record.status = 0;
                record.state = Altos.ao_flight_idle;
 
                record.tick = adc.tick;
+
                record.accel = adc.accel;
                record.pres = adc.pres;
                record.batt = adc.batt;