From 0526388bdccd53df45a7c7d884c4eccf3ef0f995 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Thu, 29 Dec 2016 17:53:04 +0000 Subject: [PATCH] Factor out sendBeastSettings(), use it in view1090. --- faup1090.c | 16 ---------------- net_io.c | 18 ++++++++++++++++++ net_io.h | 2 ++ view1090.c | 4 ++++ 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/faup1090.c b/faup1090.c index fb3a8b0..dee1f24 100644 --- a/faup1090.c +++ b/faup1090.c @@ -139,22 +139,6 @@ static void backgroundTasks(void) { modesNetPeriodicWork(); } -static void sendBeastSettings(struct client *c, const char *settings) { - int len; - char *buf, *p; - - len = strlen(settings) * 3; - buf = p = alloca(len); - - while (*settings) { - *p++ = 0x1a; - *p++ = '1'; - *p++ = *settings++; - } - - anetWrite(c->fd, buf, len); -} - // //========================================================================= // diff --git a/net_io.c b/net_io.c index cea834a..92afa6e 100644 --- a/net_io.c +++ b/net_io.c @@ -784,6 +784,24 @@ static void handle_radarcape_position(float lat, float lon, float alt) } } +// Send some Beast settings commands to a client +void sendBeastSettings(struct client *c, const char *settings) +{ + int len; + char *buf, *p; + + len = strlen(settings) * 3; + buf = p = alloca(len); + + while (*settings) { + *p++ = 0x1a; + *p++ = '1'; + *p++ = *settings++; + } + + anetWrite(c->fd, buf, len); +} + // //========================================================================= // diff --git a/net_io.h b/net_io.h index 4610ee6..c929f5d 100644 --- a/net_io.h +++ b/net_io.h @@ -72,6 +72,8 @@ struct client *createGenericClient(struct net_service *service, int fd); struct net_service *makeBeastInputService(void); struct net_service *makeFatsvOutputService(void); +void sendBeastSettings(struct client *c, const char *settings); + void modesInitNet(void); void modesQueueOutput(struct modesMessage *mm, struct aircraft *a); void modesNetPeriodicWork(void); diff --git a/view1090.c b/view1090.c index c60d3eb..c1e81f9 100644 --- a/view1090.c +++ b/view1090.c @@ -206,6 +206,10 @@ int main(int argc, char **argv) { exit(1); } + sendBeastSettings(c, "Cd"); // Beast binary format, no filters + sendBeastSettings(c, Modes.mode_ac ? "J" : "j"); // Mode A/C on or off + sendBeastSettings(c, Modes.check_crc ? "f" : "F"); // CRC checks on or off + // Keep going till the user does something that stops us while (!Modes.exit) { icaoFilterExpire();