Merge pull request #148 from mkinney/add_imports_for_lib

add imports; change interface calls
This commit is contained in:
mkinney 2021-12-21 11:33:37 -08:00 committed by GitHub
commit 25850992cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,6 +16,7 @@ Another example using Python 3 code to send a message to the mesh when WiFi is e
```python ```python
import time import time
import meshtastic import meshtastic
import meshtastic.tcp_interface
from pubsub import pub from pubsub import pub
def onReceive(packet, interface): # called when a packet arrives def onReceive(packet, interface): # called when a packet arrives
@ -27,7 +28,7 @@ def onConnection(interface, topic=pub.AUTO_TOPIC): # called when we (re)connect
pub.subscribe(onReceive, "meshtastic.receive") pub.subscribe(onReceive, "meshtastic.receive")
pub.subscribe(onConnection, "meshtastic.connection.established") pub.subscribe(onConnection, "meshtastic.connection.established")
interface = meshtastic.TCPInterface(hostname='192.168.68.74') interface = meshtastic.tcp_interface.TCPInterface(hostname='192.168.68.74')
while True: while True:
time.sleep(1000) time.sleep(1000)
interface.close() interface.close()
@ -39,7 +40,8 @@ Note: Be sure to change the ip address in the code above to a valid ip address f
You can get and update settings like this: You can get and update settings like this:
```python ```python
import meshtastic import meshtastic
interface = meshtastic.SerialInterface() import meshtastic.serial_interface
interface = meshtastic.serial_interface.SerialInterface()
ourNode = interface.getNode('^local') ourNode = interface.getNode('^local')
print(ourNode.radioConfig.preferences) print(ourNode.radioConfig.preferences)