Skip to content

Commit

Permalink
add FREQ_AS_ALT
Browse files Browse the repository at this point in the history
  • Loading branch information
rpatel3001 committed Mar 20, 2024
1 parent 11ff1d0 commit 81a896e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Under active development, everything is subject to change without notice.
| `DIST_UNIT` | The unit of the value in `MAX_DIST`. One of `km`, `m`, `mi`, `nmi`, `ft`, `in`. | `nmi` |
| `SEND_ALL` | Set to any value to send SBS messages for messages without a position. Set to `log` to also print a log entry for each non-position message. | Unset |
| `ACARS_FREQ_AS_SQUAWK`, `VDLM2_FREQ_AS_SQUAWK`, `HFDL_FREQ_AS_SQUAWK` | Set to any value to send the received frequency as the squawk value, for each incoming message type. | Unset |
| `ACARS_FREQ_AS_ALT`, `VDLM2_FREQ_AS_ALT`, `HFDL_FREQ_AS_ALT` | Set to any value to send the received frequency as the altitude value, for each incoming message type. | Unset |

## Docker Compose

Expand Down
9 changes: 8 additions & 1 deletion rootfs/scripts/acars2pos.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def generateBasestation(sbs, squawk, lat, lon):
lonstr = ''
if not squawk:
squawk = ''
return f'MSG,3,1,1,{sbs["icao"].upper()},1,{sbs_timestamp},{sbs_timestamp},{sbs_callsign},,,,{latstr},{lonstr},,{squawk},,0,,'
return f'MSG,3,1,1,{sbs["icao"].upper()},1,{sbs_timestamp},{sbs_timestamp},{sbs_callsign},{sbs["alt"]},,,{latstr},{lonstr},,{squawk},,0,,'

# wrapper to catch exceptions and restart threads
def thread_wrapper(func, *args):
Expand Down Expand Up @@ -121,19 +121,26 @@ def thread_wrapper(func, *args):
print(f'{Fore.GREEN}xxxxxxx {sbs["reg"]}{Fore.RESET}', file=stderr)
continue

sbs["alt"] = ""
if sbs["type"] == "acars":
if getenv("ACARS_FREQ_AS_ALT"):
sbs["alt"] = f"{round(sbs['freq']/1000-100000):d}"
if getenv("ACARS_FREQ_AS_SQUAWK"):
squawk = f"{round(sbs['freq']/1000-100000):d}"
else:
squawk = "1111"
elif sbs["type"] == "vdlm2":
if getenv("VDLM2_FREQ_AS_ALT"):
sbs["alt"] = f"{round(sbs['freq']/1000-100000):d}"
if getenv("VDLM2_FREQ_AS_SQUAWK"):
squawk = f"{round(sbs['freq']/1000-100000):d}"
elif sbs.get("xid"):
squawk = "2220"
else:
squawk = "2222"
elif sbs["type"] == "hfdl":
if getenv("HFDL_FREQ_AS_ALT"):
sbs["alt"] = f"{round(sbs['freq']/1000):d}"
if getenv("HFDL_FREQ_AS_SQUAWK"):
squawk = f"{round(sbs['freq']/1000):d}"
else:
Expand Down

0 comments on commit 81a896e

Please sign in to comment.