From 5b992734fb3b9014d4ef0bc0f2e5b950179d3be7 Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Wed, 12 Jan 2022 10:57:03 -0800 Subject: [PATCH] add example how you can get the hwModel using api --- examples/get_hw.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 examples/get_hw.py diff --git a/examples/get_hw.py b/examples/get_hw.py new file mode 100644 index 0000000..751e2e2 --- /dev/null +++ b/examples/get_hw.py @@ -0,0 +1,20 @@ +"""Simple program to demo how to use meshtastic library. + To run: python examples/get_hw.py +""" + +import sys +import meshtastic +import meshtastic.serial_interface + +# simple arg check +if len(sys.argv) != 1: + print(f"usage: {sys.argv[0]}") + print("Print the hardware model for the local node.") + sys.exit(3) + +iface = meshtastic.serial_interface.SerialInterface() +if iface.nodes: + for n in iface.nodes.values(): + if n['num'] == iface.myInfo.my_node_num: + print(n['user']['hwModel']) +iface.close()