minor changes: cleanup todo, correction help message, naming sniffer->mqtt_sniffer
This commit is contained in:
parent
9b2141ff55
commit
c9103de08e
@ -10,14 +10,13 @@ import time
|
|||||||
VERSION = "0.1.0"
|
VERSION = "0.1.0"
|
||||||
STARTTIME = time.time()
|
STARTTIME = time.time()
|
||||||
# TODO: Implement default values for bottombar_entries
|
# TODO: Implement default values for bottombar_entries
|
||||||
# TODO: Implement the Filter functionality
|
|
||||||
|
|
||||||
HELPTEXT = """
|
HELPTEXT = """
|
||||||
F1: Get this help message
|
F1: Get this help message
|
||||||
F2: Set a filter (regular expression) for the topic of a message
|
F2: Set a filter (regular expression) for the topic of a message
|
||||||
Examples:
|
Examples:
|
||||||
* "/gfw/*/videv" Get everything with "/gfw/" before "/videv"
|
* "/gfw/.*/videv" Get everything with "/gfw/" before "/videv"
|
||||||
F9: Start / Stop logging to mqtt-sniffer.log
|
F9: Start / Stop logging to mqtt_sniffer.log
|
||||||
F12: Quit the mqtt sniffer
|
F12: Quit the mqtt sniffer
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -42,9 +41,9 @@ def rx_mqtt(mc, userdata, message):
|
|||||||
data = message.payload
|
data = message.payload
|
||||||
|
|
||||||
if match:
|
if match:
|
||||||
print("%9.04f::%30s::%s" % (ts, message.topic, data))
|
print("%9.04f::%75s::%s" % (ts, message.topic, data))
|
||||||
if my_bb.get_entry('log2file'):
|
if my_bb.get_entry('log2file'):
|
||||||
logfile.write("%9.04f::%30s::%s\n" % (ts, message.topic, data))
|
logfile.write("%9.04f::%s::%s\n" % (ts, message.topic, data))
|
||||||
logfile.flush()
|
logfile.flush()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
@ -68,7 +67,7 @@ if __name__ == "__main__":
|
|||||||
my_bb.add_entry('msg_re', 2, my_bb.FUNC_TEXT, label='[F2] Filter')
|
my_bb.add_entry('msg_re', 2, my_bb.FUNC_TEXT, label='[F2] Filter')
|
||||||
my_bb.add_entry('quit', 12, my_bb.FUNC_QUIT, "Quit", label='[F12]', right=True)
|
my_bb.add_entry('quit', 12, my_bb.FUNC_QUIT, "Quit", label='[F12]', right=True)
|
||||||
my_bb.add_entry('log2file', 9, my_bb.FUNC_BOOL, label='[F9] Log2File', right=True)
|
my_bb.add_entry('log2file', 9, my_bb.FUNC_BOOL, label='[F9] Log2File', right=True)
|
||||||
with open('sniffer.log', 'w') as logfile:
|
with open('mqtt_sniffer.log', 'w') as logfile:
|
||||||
mc = mqtt.mqtt_client("sniffer", args.hostname, port=args.port, username=args.username, password=password)
|
mc = mqtt.mqtt_client("mqtt_sniffer", args.hostname, port=args.port, username=args.username, password=password)
|
||||||
mc.add_callback("#", rx_mqtt)
|
mc.add_callback("#", rx_mqtt)
|
||||||
my_bb.run()
|
my_bb.run()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user