From 237b7504973b83c7162e85708272ec29eabff7b0 Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Tue, 7 Dec 2021 09:42:27 -0800 Subject: [PATCH] fix pylint warnings; remove old doc --- meshtastic/__main__.py | 2 +- meshtastic/node.py | 57 +---------------------------------- meshtastic/remote_hardware.py | 1 + 3 files changed, 3 insertions(+), 57 deletions(-) diff --git a/meshtastic/__main__.py b/meshtastic/__main__.py index 2a22038..4650919 100644 --- a/meshtastic/__main__.py +++ b/meshtastic/__main__.py @@ -269,7 +269,7 @@ def onConnected(interface): fieldNames = [] for bit in radioconfig_pb2.PositionFlags.values(): - if (prefs.position_flags & bit): + if prefs.position_flags & bit: fieldNames.append(radioconfig_pb2.PositionFlags.Name(bit)) print(' '.join(fieldNames)) diff --git a/meshtastic/node.py b/meshtastic/node.py index ecd62aa..0631cc4 100644 --- a/meshtastic/node.py +++ b/meshtastic/node.py @@ -1,63 +1,8 @@ -""" -# an API for Meshtastic devices - -Primary class: SerialInterface -Install with pip: "[pip3 install meshtastic](https://pypi.org/project/meshtastic/)" -Source code on [github](https://github.com/meshtastic/Meshtastic-python) - -properties of SerialInterface: - -- radioConfig - Current radio configuration and device settings, if you write to this the new settings will be applied to -the device. -- nodes - The database of received nodes. Includes always up-to-date location and username information for each -node in the mesh. This is a read-only datastructure. -- nodesByNum - like "nodes" but keyed by nodeNum instead of nodeId -- myInfo - Contains read-only information about the local radio device (software version, hardware version, etc) - -# Published PubSub topics - -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 -- meshtastic.connection.lost - published once we've lost our link to the radio -- meshtastic.receive.text(packet) - delivers a received packet as a dictionary, if you only care about a particular -type of packet, you should subscribe to the full topic name. If you want to see all packets, simply subscribe to "meshtastic.receive". -- meshtastic.receive.position(packet) -- meshtastic.receive.user(packet) -- meshtastic.receive.data.portnum(packet) (where portnum is an integer or well known PortNum enum) -- meshtastic.node.updated(node = NodeInfo) - published when a node in the DB changes (appears, location changed, username changed, etc...) - -We receive position, user, or data packets from the mesh. You probably only care about meshtastic.receive.data. The first argument for -that publish will be the packet. Text or binary data packets (from sendData or sendText) will both arrive this way. If you print packet -you'll see the fields in the dictionary. decoded.data.payload will contain the raw bytes that were sent. If the packet was sent with -sendText, decoded.data.text will **also** be populated with the decoded string. For ASCII these two strings will be the same, but for -unicode scripts they can be different. - -# Example Usage -``` -import meshtastic -from pubsub import pub - -def onReceive(packet, interface): # called when a packet arrives - print(f"Received: {packet}") - -def onConnection(interface, topic=pub.AUTO_TOPIC): # called when we (re)connect to the radio - # defaults to broadcast, specify a destination ID if you wish - interface.sendText("hello mesh") - -pub.subscribe(onReceive, "meshtastic.receive") -pub.subscribe(onConnection, "meshtastic.connection.established") -# By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0 -interface = meshtastic.SerialInterface() - -``` - +""" Node class """ import logging import base64 -from typing import * from google.protobuf.json_format import MessageToJson from . import portnums_pb2, apponly_pb2, admin_pb2, channel_pb2 from .util import pskToString, stripnl, Timeout diff --git a/meshtastic/remote_hardware.py b/meshtastic/remote_hardware.py index 4357607..2e0dac9 100644 --- a/meshtastic/remote_hardware.py +++ b/meshtastic/remote_hardware.py @@ -38,6 +38,7 @@ class RemoteHardwareClient: def _sendHardware(self, nodeid, r, wantResponse=False, onResponse=None): if not nodeid: + # pylint: disable=W1401 raise Exception( "You must set a destination node ID for this operation (use --dest \!xxxxxxxxx)") return self.iface.sendData(r, nodeid, portnums_pb2.REMOTE_HARDWARE_APP,