mirror of
https://github.com/craigerl/aprsd.git
synced 2024-12-20 08:31:11 -05:00
Added --raw format for sending messages
aprsd send-message --raw "RAW APRS MESSAGE HERE"
This commit is contained in:
parent
f022a3e421
commit
54072a2103
@ -234,8 +234,9 @@ def sample_config():
|
||||
default=False,
|
||||
help="Don't wait for an ack, just sent it to APRS-IS and bail.",
|
||||
)
|
||||
@click.argument("tocallsign")
|
||||
@click.argument("command", nargs=-1)
|
||||
@click.option("--raw", default=None, help="Send a raw message. Implies --no-ack")
|
||||
@click.argument("tocallsign", required=False)
|
||||
@click.argument("command", nargs=-1, required=False)
|
||||
def send_message(
|
||||
loglevel,
|
||||
quiet,
|
||||
@ -243,15 +244,13 @@ def send_message(
|
||||
aprs_login,
|
||||
aprs_password,
|
||||
no_ack,
|
||||
raw,
|
||||
tocallsign,
|
||||
command,
|
||||
):
|
||||
"""Send a message to a callsign via APRS_IS."""
|
||||
global got_ack, got_response
|
||||
|
||||
if not quiet:
|
||||
click.echo("{} {} {} {}".format(aprs_login, aprs_password, tocallsign, command))
|
||||
click.echo("Load config")
|
||||
config = utils.parse_config(config_file)
|
||||
if not aprs_login:
|
||||
click.echo("Must set --aprs_login or APRS_LOGIN")
|
||||
@ -269,7 +268,11 @@ def send_message(
|
||||
LOG.info("APRSD Started version: {}".format(aprsd.__version__))
|
||||
if type(command) is tuple:
|
||||
command = " ".join(command)
|
||||
LOG.info("Sending Command '{}'".format(command))
|
||||
if not quiet:
|
||||
if raw:
|
||||
LOG.info("L'{}' R'{}'".format(aprs_login, raw))
|
||||
else:
|
||||
LOG.info("L'{}' To'{}' C'{}'".format(aprs_login, tocallsign, command))
|
||||
|
||||
got_ack = False
|
||||
got_response = False
|
||||
@ -317,7 +320,12 @@ def send_message(
|
||||
# We should get an ack back as well as a new message
|
||||
# we should bail after we get the ack and send an ack back for the
|
||||
# message
|
||||
msg = messaging.TextMessage(aprs_login, tocallsign, command)
|
||||
if raw:
|
||||
msg = messaging.RawMessage(raw)
|
||||
msg.send_direct()
|
||||
sys.exit(0)
|
||||
else:
|
||||
msg = messaging.TextMessage(aprs_login, tocallsign, command)
|
||||
msg.send_direct()
|
||||
|
||||
if no_ack:
|
||||
|
@ -212,6 +212,46 @@ class Message(metaclass=abc.ABCMeta):
|
||||
pass
|
||||
|
||||
|
||||
class RawMessage(Message):
|
||||
"""Send a raw message.
|
||||
|
||||
This class is used for custom messages that contain the entire
|
||||
contents of an APRS message in the message field.
|
||||
|
||||
"""
|
||||
|
||||
message = None
|
||||
|
||||
def __init__(self, message):
|
||||
super().__init__(None, None, msg_id=None)
|
||||
self.message = message
|
||||
|
||||
def __repr__(self):
|
||||
return self.message
|
||||
|
||||
def __str__(self):
|
||||
return self.message
|
||||
|
||||
def send(self):
|
||||
tracker = MsgTrack()
|
||||
tracker.add(self)
|
||||
LOG.debug("Length of MsgTrack is {}".format(len(tracker)))
|
||||
thread = SendMessageThread(message=self)
|
||||
thread.start()
|
||||
|
||||
def send_direct(self):
|
||||
"""Send a message without a separate thread."""
|
||||
cl = client.get_client()
|
||||
log_message(
|
||||
"Sending Message Direct",
|
||||
repr(self).rstrip("\n"),
|
||||
self.message,
|
||||
tocall=self.tocall,
|
||||
fromcall=self.fromcall,
|
||||
)
|
||||
cl.sendall(repr(self))
|
||||
|
||||
|
||||
class TextMessage(Message):
|
||||
"""Send regular ARPS text/command messages/replies."""
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user