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()