receiver.json support, internal webserver cleanup.
Add data/receiver.json (generated once) and support for it in script.js. Internal webserver rearrangement to support multiple json files.
This commit is contained in:
parent
f707f2cdce
commit
9fa09e0e92
5 changed files with 138 additions and 58 deletions
19
dump1090.c
19
dump1090.c
|
|
@ -634,14 +634,15 @@ void backgroundTasks(void) {
|
|||
}
|
||||
}
|
||||
|
||||
if (Modes.json_path && Modes.json_interval > 0) {
|
||||
if (Modes.json_aircraft_path && Modes.json_interval > 0) {
|
||||
time_t now = time(NULL);
|
||||
if (now >= next_json) {
|
||||
modesWriteJson(Modes.json_path);
|
||||
writeJsonToFile(Modes.json_aircraft_path, generateAircraftJson);
|
||||
next_json = now + Modes.json_interval;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//=========================================================================
|
||||
//
|
||||
|
|
@ -837,9 +838,13 @@ int main(int argc, char **argv) {
|
|||
#ifndef _WIN32
|
||||
} else if (!strcmp(argv[j], "--write-json") && more) {
|
||||
++j;
|
||||
Modes.json_path = malloc(strlen(argv[j]) + 15);
|
||||
strcpy(Modes.json_path, argv[j]);
|
||||
strcat(Modes.json_path, "/aircraft.json");
|
||||
Modes.json_aircraft_path = malloc(strlen(argv[j]) + 15);
|
||||
strcpy(Modes.json_aircraft_path, argv[j]);
|
||||
strcat(Modes.json_aircraft_path, "/aircraft.json");
|
||||
|
||||
Modes.json_metadata_path = malloc(strlen(argv[j]) + 15);
|
||||
strcpy(Modes.json_metadata_path, argv[j]);
|
||||
strcat(Modes.json_metadata_path, "/receiver.json");
|
||||
} else if (!strcmp(argv[j], "--write-json-every") && more) {
|
||||
Modes.json_interval = atoi(argv[++j]);
|
||||
#endif
|
||||
|
|
@ -908,6 +913,10 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
if (Modes.net) modesInitNet();
|
||||
|
||||
if (Modes.json_metadata_path && Modes.json_interval > 0) {
|
||||
writeJsonToFile(Modes.json_metadata_path, generateReceiverJson); // once only on startup
|
||||
}
|
||||
|
||||
// If the user specifies --net-only, just run in order to serve network
|
||||
// clients without reading data from the RTL device
|
||||
while (Modes.net_only) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue