diff --git a/dump1090.h b/dump1090.h index baca8d1..3628d76 100644 --- a/dump1090.h +++ b/dump1090.h @@ -623,6 +623,7 @@ unsigned modeCToModeA (int modeC); void interactiveInit(void); void interactiveShowData(void); void interactiveCleanup(void); +void interactiveNoConnection(void); // Provided by dump1090.c / view1090.c / faup1090.c void receiverPositionChanged(float lat, float lon, float alt); diff --git a/interactive.c b/interactive.c index c1782a8..3e36448 100644 --- a/interactive.c +++ b/interactive.c @@ -84,9 +84,6 @@ void interactiveInit() { initscr(); clear(); refresh(); - - mvprintw(0, 0, " Hex Mode Sqwk Flight Alt Spd Hdg Lat Long RSSI Msgs Ti"); - mvhline(1, 0, ACS_HLINE, 80); } void interactiveCleanup(void) { @@ -95,6 +92,14 @@ void interactiveCleanup(void) { } } +void interactiveNoConnection(void) { + if (!Modes.interactive) + return; + + mvprintw(0, 0, " /!\\ input connection lost /!\\ "); + refresh(); +} + void interactiveShowData(void) { struct aircraft *a = Modes.aircrafts; static uint64_t next_update; @@ -102,12 +107,18 @@ void interactiveShowData(void) { char progress; char spinner[4] = "|/-\\"; + if (!Modes.interactive) + return; + // Refresh screen every (MODES_INTERACTIVE_REFRESH_TIME) miliseconde if (now < next_update) return; next_update = now + MODES_INTERACTIVE_REFRESH_TIME; + mvprintw(0, 0, " Hex Mode Sqwk Flight Alt Spd Hdg Lat Long RSSI Msgs Ti"); + mvhline(1, 0, ACS_HLINE, 80); + progress = spinner[(now/1000)%4]; mvaddch(0, 79, progress); diff --git a/view1090.c b/view1090.c index e5b8fa0..51bce9c 100644 --- a/view1090.c +++ b/view1090.c @@ -100,7 +100,6 @@ void view1090Init(void) { modesChecksumInit(Modes.nfix_crc); icaoFilterInit(); modeACInit(); - interactiveInit(); } // @@ -210,23 +209,25 @@ int main(int argc, char **argv) { s = makeBeastInputService(); c = serviceConnect(s, bo_connect_ipaddr, bo_connect_port); if (!c) { + interactiveCleanup(); fprintf(stderr, "Failed to connect to %s:%d: %s\n", bo_connect_ipaddr, bo_connect_port, Modes.aneterr); exit(1); } sendSettings(c); // Keep going till the user does something that stops us + interactiveInit(); while (!Modes.exit) { struct timespec r = { 0, 100 * 1000 * 1000}; icaoFilterExpire(); trackPeriodicUpdate(); modesNetPeriodicWork(); - if (Modes.interactive) - interactiveShowData(); + interactiveShowData(); if (s->connections == 0) { // lost input connection, try to reconnect + interactiveNoConnection(); sleep(1); c = serviceConnect(s, bo_connect_ipaddr, bo_connect_port); if (c) {