Skip to content

Commit

Permalink
Put a warning header up in view1090 interactive mode when there's no …
Browse files Browse the repository at this point in the history
…connection
  • Loading branch information
mutability committed Dec 2, 2019
1 parent fb11080 commit a224f6f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions dump1090.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 14 additions & 3 deletions interactive.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -95,19 +92,33 @@ 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;
uint64_t now = mstime();
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);

Expand Down
7 changes: 4 additions & 3 deletions view1090.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ void view1090Init(void) {
modesChecksumInit(Modes.nfix_crc);
icaoFilterInit();
modeACInit();
interactiveInit();
}

//
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit a224f6f

Please sign in to comment.