Put a warning header up in view1090 interactive mode when there's no connection

This commit is contained in:
Oliver Jowett 2019-12-02 19:51:06 +08:00
parent fb110802d6
commit a224f6f783
3 changed files with 19 additions and 6 deletions

View File

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

View File

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

View File

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