Skip to content

Commit b04501d

Browse files
committed
2nd attempt:
Added SAPI5 speech for planes entering and leaving. Also speak when a new network client gets accepted or denied.
1 parent e9b1d42 commit b04501d

File tree

8 files changed

+152
-86
lines changed

8 files changed

+152
-86
lines changed

dump1090.cfg

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ aircrafts-url = https://s3.opensky-network.org/data-samples/metadata/aircraftDat
5353
airports = %~dp0\airport-codes.csv
5454

5555
#
56-
# Prefer using ADSB-LOL over 'routes.csv' or a generated 'routes.c' file.
57-
# Regardless of 'USE_GEN_ROUTES = 1' in 'Makefile.Windows'.
56+
# Prefer using ADSB-LOL over a generated
57+
# %TEMP%/dump1090/standing-data/results/routes.bin
58+
#
59+
# file. Regardless of 'USE_BIN_FILES = 1' in 'Makefile.Windows'.
5860
#
5961
prefer-adsb-lol = false
6062

@@ -163,6 +165,15 @@ web-page = %~dp0\web_root-Tar1090\index.html # The default web-page.
163165
#
164166
# sdrconsole-in = tcp://localhost:50101
165167

168+
#
169+
# Speech settings.
170+
# Have SAPI5 speak when a plane is entering or leaving.
171+
# Or when a client is accepted or denied.
172+
#
173+
speech-enable = true
174+
speech-volume = 70 # 0 - 100
175+
# speech-voice = x # to-do
176+
166177
#
167178
# Internal values for 'dump1090.exe --test=config':
168179
#

src/Dump1090.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@
158158
<ClCompile Include="net_io.c" />
159159
<ClCompile Include="pconsole.c" />
160160
<ClCompile Include="sdrplay.c" />
161+
<ClCompile Include="speech.c" />
161162
<ClCompile Include="externals\mongoose.c" />
162163
<ClCompile Include="externals\Curses\amalgamation.c" />
163164
<ClCompile Include="externals\sqlite3.c" />
@@ -179,6 +180,7 @@
179180
<ClInclude Include="misc.h" />
180181
<ClInclude Include="net_io.h" />
181182
<ClInclude Include="sdrplay.h" />
183+
<ClInclude Include="speech.h" />
182184
<ClInclude Include="dump1090_config.h" />
183185
<ClInclude Include="externals\mongoose.h" />
184186
<ClInclude Include="externals\sqlite3.h" />

src/dump1090.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "net_io.h"
2424
#include "cfg_file.h"
2525
#include "sdrplay.h"
26+
#include "speech.h"
2627
#include "location.h"
2728
#include "airports.h"
2829
#include "interactive.h"
@@ -158,6 +159,8 @@ static const struct cfg_table config[] = {
158159
{ "rtl-reset", ARG_ATOB, (void*) &Modes.rtlsdr.power_cycle },
159160
{ "samplerate", ARG_FUNC, (void*) set_sample_rate },
160161
{ "show-hostname", ARG_ATOB, (void*) &Modes.show_host_name },
162+
{ "speech-enable", ARG_ATOB, (void*) &Modes.speech_enable },
163+
{ "speech-volume", ARG_ATOI, (void*) &Modes.speech_volume },
161164
{ "https-enable", ARG_ATOB, (void*) &Modes.https_enable },
162165
{ "silent", ARG_ATOB, (void*) &Modes.silent },
163166
{ "ppm", ARG_FUNC, (void*) set_ppm },
@@ -486,6 +489,12 @@ static bool modeS_init (void)
486489
if (Modes.logfile_initial[0])
487490
modeS_init_log();
488491

492+
if (Modes.speech_enable && !speak_init(0, Modes.speech_volume))
493+
{
494+
LOG_FILEONLY ("speak_init(): failed.\n");
495+
Modes.speech_enable = false;
496+
}
497+
489498
modeS_log_set();
490499
aircraft_SQL_set_name();
491500

@@ -3334,6 +3343,8 @@ static void modeS_exit (void)
33343343
if (Modes.win_location)
33353344
location_exit();
33363345

3346+
speak_exit();
3347+
33373348
modeS_log_exit();
33383349

33393350
#if defined(_DEBUG)
@@ -3638,7 +3649,7 @@ static bool set_prefer_adsb_lol (const char *arg)
36383649
{
36393650
Modes.prefer_adsb_lol = cfg_true (arg);
36403651

3641-
#if !defined(USE_GEN_ROUTES) && !defined(USE_BIN_FILES)
3652+
#if !defined(USE_BIN_FILES)
36423653
DEBUG (DEBUG_GENERAL,
36433654
"Config value 'prefer-adsb-lol=%d' has no meaning.\n"
36443655
"Will always use ADSB-LOL API to lookup routes in 'airports.c'.\n",

src/misc.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
#include "misc.h"
2727
#include "rtl-sdr/version.h"
2828

29+
#define __SpeechConstants_MODULE_DEFINED__
30+
#include <sapi.h>
31+
2932
#define TSIZE (int)(sizeof("HH:MM:SS.MMM: ") - 1)
3033

3134
static bool modeS_log_reinit (const SYSTEMTIME *st);
@@ -1264,6 +1267,14 @@ static void print_sql_info (void)
12641267
free (buf);
12651268
}
12661269

1270+
/**
1271+
* Print the SAPI (Speech API) version.
1272+
*/
1273+
static void print_SAPI_info (void)
1274+
{
1275+
printf ("SAPI ver: %x.%x\n", (_SAPI_VER & 0xF0) >> 4, _SAPI_VER & 0x0F);
1276+
}
1277+
12671278
/**
12681279
* Return the compiler info the program was built with.
12691280
*/
@@ -1314,9 +1325,6 @@ static const char *build_features (void)
13141325
#if defined(USE_UBSAN)
13151326
"UBSAN",
13161327
#endif
1317-
#if defined(USE_GEN_ROUTES)
1318-
"GEN_ROUTES",
1319-
#endif
13201328
#if defined(USE_BIN_FILES)
13211329
"BIN_FILES",
13221330
#endif
@@ -1624,7 +1632,7 @@ static void print_BIN_files (void)
16241632
"routes.bin"
16251633
};
16261634

1627-
printf ("Generated .BIN-files:\n");
1635+
printf ("\nGenerated .BIN-files:\n");
16281636

16291637
init_timings(); /* for 'Modes.timezone' */
16301638

@@ -1670,6 +1678,7 @@ void show_version_info (bool verbose)
16701678
printf ("RTL-SDR ver: %d.%d.%d.%d from https://%s\n",
16711679
RTLSDR_MAJOR, RTLSDR_MINOR, RTLSDR_MICRO, RTLSDR_NANO, RTL_VER_ID);
16721680
printf ("PDCurses ver: %-7s from https://github.com/wmcbrine/PDCurses\n", PDC_VERDOT);
1681+
print_SAPI_info();
16731682
print_sql_info();
16741683
print_BIN_files();
16751684
print_CFLAGS();

src/misc.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,10 +463,12 @@ typedef struct global_data {
463463
int win_location; /**< Use 'Windows Location API' to get the 'Modes.home_pos'. */
464464
int only_addr; /**< Print only ICAO addresses. */
465465
int metric; /**< Use metric units. */
466-
int prefer_adsb_lol; /**< Prefer using ADSB-LOL API even with '-DUSE_GEN_ROUTES' and/or '-DUSE_BIN_FILES'. */
466+
int prefer_adsb_lol; /**< Prefer using ADSB-LOL API even with '-DUSE_BIN_FILES'. */
467467
bool error_correct_1; /**< Fix 1 bit errors (default: true). */
468468
bool error_correct_2; /**< Fix 2 bit errors (default: false). */
469469
int keep_alive; /**< Send "Connection: keep-alive" if HTTP client sends it. */
470+
int speech_enable; /**< Enable speech for planes entering and leaving. */
471+
int speech_volume; /**< Speech volume; 0 - 100 percent */
470472
mg_file_path web_page; /**< The base-name of the web-page to server for HTTP clients. */
471473
mg_file_path web_root; /**< And it's directory. */
472474
bool web_root_touch; /**< Touch all files in `web_root` first. */

src/net_io.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "aircraft.h"
1212
#include "net_io.h"
1313
#include "rtl-tcp.h"
14+
#include "speech.h"
1415
#include "server-cert-key.h"
1516
#include "client-cert-key.h"
1617

@@ -1550,7 +1551,7 @@ static bool client_is_extern (const mg_addr *addr)
15501551
static bool client_handler (mg_connection *c, intptr_t service, int ev)
15511552
{
15521553
const mg_addr *addr = &c->rem;
1553-
const char *is_tls = "";
1554+
const char *ip, *is_tls = "";
15541555
mg_host_name addr_buf;
15551556
unique_IP *unique;
15561557

@@ -1577,13 +1578,22 @@ static bool client_handler (mg_connection *c, intptr_t service, int ev)
15771578
if (deny && unique) /* increment deny-counter for this `addr` */
15781579
unique->denied++;
15791580

1580-
if (Modes.debug & DEBUG_NET)
1581-
Beep (deny ? 1200 : 800, 20);
1581+
net_str_addr (addr, addr_buf, sizeof(addr_buf));
1582+
1583+
if (Modes.speech_enable)
1584+
{
1585+
speak_string ("Client for %s %s.",
1586+
net_service_descr(service),
1587+
deny ? "denied" : "accepted");
1588+
}
1589+
else if (Modes.debug & DEBUG_NET)
1590+
{
1591+
Beep (deny ? 1200 : 800, 20);
1592+
}
15821593

15831594
LOG_FILEONLY ("%s connection: %s (conn-id: %lu, service: \"%s\"%s).\n",
15841595
deny ? "Denied" : "Accepted",
1585-
net_str_addr(addr, addr_buf, sizeof(addr_buf)),
1586-
c->id, net_service_descr(service), is_tls);
1596+
addr_buf, c->id, net_service_descr(service), is_tls);
15871597
return (!deny);
15881598
}
15891599
}

0 commit comments

Comments
 (0)