mirror of
https://github.com/meshtastic/python.git
synced 2026-01-16 19:58:04 -05:00
fix examples
This commit is contained in:
@@ -15,7 +15,7 @@ then run the following python3 code:
|
||||
```
|
||||
import meshtastic
|
||||
interface = meshtastic.StreamInterface() # By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0
|
||||
interface.sendData("hello world")
|
||||
interface.sendData("hello mesh")
|
||||
```
|
||||
|
||||
For the rough notes/implementation plan see [TODO](https://github.com/meshtastic/Meshtastic-python/blob/master/TODO.md).
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<section id="section-intro">
|
||||
<h2 id="an-api-for-meshtastic-devices">an API for Meshtastic devices</h2>
|
||||
<p>Primary class: StreamInterface
|
||||
Install with pip: "pip3 install meshtastic"
|
||||
Install with pip: "<a href="https://pypi.org/project/meshtastic/">pip3 install meshtastic</a>"
|
||||
Source code on <a href="https://github.com/meshtastic/Meshtastic-python">github</a></p>
|
||||
<p>properties of StreamInterface:</p>
|
||||
<ul>
|
||||
@@ -56,11 +56,12 @@ def onReceive(packet): # called when a packet arrives
|
||||
print(f"Received: {packet}")
|
||||
|
||||
def onConnection(): # called when we (re)connect to the radio
|
||||
interface.sendData("hello world") # defaults to broadcast, specify a destination ID if you wish
|
||||
interface.sendText("hello mesh") # defaults to broadcast, specify a destination ID if you wish
|
||||
|
||||
interface = meshtastic.StreamInterface() # By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0
|
||||
pub.subscribe(onReceive, "meshtastic.receive")
|
||||
pub.subscribe(onConnection, "meshtastic.connection.established")
|
||||
interface = meshtastic.StreamInterface() # By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0
|
||||
|
||||
</code></pre>
|
||||
<details class="source">
|
||||
<summary>
|
||||
@@ -70,7 +71,7 @@ pub.subscribe(onConnection, "meshtastic.connection.established")
|
||||
## an API for Meshtastic devices
|
||||
|
||||
Primary class: StreamInterface
|
||||
Install with pip: "pip3 install meshtastic"
|
||||
Install with pip: "[pip3 install meshtastic](https://pypi.org/project/meshtastic/)"
|
||||
Source code on [github](https://github.com/meshtastic/Meshtastic-python)
|
||||
|
||||
properties of StreamInterface:
|
||||
@@ -103,11 +104,12 @@ def onReceive(packet): # called when a packet arrives
|
||||
print(f"Received: {packet}")
|
||||
|
||||
def onConnection(): # called when we (re)connect to the radio
|
||||
interface.sendData("hello world") # defaults to broadcast, specify a destination ID if you wish
|
||||
interface.sendText("hello mesh") # defaults to broadcast, specify a destination ID if you wish
|
||||
|
||||
interface = meshtastic.StreamInterface() # By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0
|
||||
pub.subscribe(onReceive, "meshtastic.receive")
|
||||
pub.subscribe(onConnection, "meshtastic.connection.established")
|
||||
interface = meshtastic.StreamInterface() # By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0
|
||||
|
||||
```
|
||||
|
||||
"""
|
||||
|
||||
@@ -35,11 +35,12 @@ def onReceive(packet): # called when a packet arrives
|
||||
print(f"Received: {packet}")
|
||||
|
||||
def onConnection(): # called when we (re)connect to the radio
|
||||
interface.sendData("hello world") # defaults to broadcast, specify a destination ID if you wish
|
||||
interface.sendText("hello mesh") # defaults to broadcast, specify a destination ID if you wish
|
||||
|
||||
interface = meshtastic.StreamInterface() # By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0
|
||||
pub.subscribe(onReceive, "meshtastic.receive")
|
||||
pub.subscribe(onConnection, "meshtastic.connection.established")
|
||||
interface = meshtastic.StreamInterface() # By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0
|
||||
|
||||
```
|
||||
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user