From e0ad07a8915d2f9e59037c25e9b15dc9c2132f08 Mon Sep 17 00:00:00 2001 From: geeksville Date: Tue, 28 Apr 2020 15:10:31 -0700 Subject: [PATCH] docs update --- README.md | 3 +-- meshtastic/__init__.py | 16 ++++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 98fd713..8e3af4f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ A python client for using Meshtastic devices. This small library (and example application) provides an easy API for sending and receiving messages over mesh radios. It also provides access to any of the operations/data available in the device user interface or the Android application. Events are delivered using a publish-subscribe model, and you can subscribe to only the message types you are interested in. -You probably don't want this yet because it is a pre-alpha WIP. +Full documentation including examples and installation instructions [here](https://meshtastic.github.io/Meshtastic-python/meshtastic/index.html). -For the API documentation [click here](https://meshtastic.github.io/Meshtastic-python/meshtastic/index.html). For the rough notes/implementation plan see [TODO](./TODO.md). diff --git a/meshtastic/__init__.py b/meshtastic/__init__.py index f9b728b..f3a4a1d 100644 --- a/meshtastic/__init__.py +++ b/meshtastic/__init__.py @@ -2,6 +2,8 @@ ## an API for Meshtastic devices Primary class: StreamInterface +Install with pip: "pip3 install meshtastic" +Source code on [github](https://github.com/meshtastic/Meshtastic-python) properties of StreamInterface: @@ -13,7 +15,7 @@ node in the mesh. This is a read-only datastructure. ## Published PubSub topics -We use a publish-subscribe model to communicate asynchronous events [https://pypubsub.readthedocs.io/en/v4.0.3/ ]. Available +We use a [publish-subscribe](https://pypubsub.readthedocs.io/en/v4.0.3/) model to communicate asynchronous events. Available topics: - meshtastic.connection.established - published once we've successfully connected to the radio and downloaded the node DB @@ -24,18 +26,20 @@ type of packet, you should subscribe to the full topic name. If you want to see - meshtastic.receive.data(packet) - meshtastic.node.updated(node = NodeInfo) - published when a node in the DB changes (appears, location changed, username changed, etc...) -Example Usage: - +## Example Usage ``` import meshtastic from pubsub import pub -def onReceive(packet): +def onReceive(packet): # called when a packet arrives print(f"Received: {packet}") -interface = StreamInterface() # By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0 +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 = meshtastic.StreamInterface() # By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0 pub.subscribe(onReceive, "meshtastic.receive") -interface.sendData("hello world") # defaults to broadcast, specify a destination ID if you wish +pub.subscribe(onConnection, "meshtastic.connection.established") ``` """