From ef9441e7d24a6100ffc686f5cf3d315c86eb0db7 Mon Sep 17 00:00:00 2001 From: Mike Schiraldi Date: Mon, 14 Mar 2022 23:32:42 -0700 Subject: [PATCH 1/2] Added examples/tcp_gps_example.py --- examples/tcp_gps_example.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 examples/tcp_gps_example.py diff --git a/examples/tcp_gps_example.py b/examples/tcp_gps_example.py new file mode 100644 index 0000000..4c55e8c --- /dev/null +++ b/examples/tcp_gps_example.py @@ -0,0 +1,12 @@ +import sys +import meshtastic +import meshtastic.tcp_interface + +node_ip = "192.168.42.1" +iface = meshtastic.tcp_interface.TCPInterface(node_ip) +my_node_num = iface.myInfo.my_node_num +pos = iface.nodesByNum[my_node_num]["position"] +print (pos) + +iface.close() + From 3332271a97eddb3291ada315011165305ec46d57 Mon Sep 17 00:00:00 2001 From: Mike Schiraldi Date: Tue, 22 Mar 2022 12:41:50 -0700 Subject: [PATCH 2/2] lint --- examples/tcp_gps_example.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/tcp_gps_example.py b/examples/tcp_gps_example.py index 4c55e8c..6bb064e 100644 --- a/examples/tcp_gps_example.py +++ b/examples/tcp_gps_example.py @@ -1,12 +1,14 @@ -import sys +"""Demonstration of how to look up a radio's location via its LAN connection. + Before running, connect your machine to the same WiFi network as the radio. +""" + import meshtastic import meshtastic.tcp_interface -node_ip = "192.168.42.1" -iface = meshtastic.tcp_interface.TCPInterface(node_ip) +radio_hostname = "meshtastic.local" # Can also be an IP +iface = meshtastic.tcp_interface.TCPInterface(radio_hostname) my_node_num = iface.myInfo.my_node_num pos = iface.nodesByNum[my_node_num]["position"] print (pos) iface.close() -