mirror of
https://github.com/meshtastic/python.git
synced 2025-12-25 17:07:53 -05:00
Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0738e5ec6d | ||
|
|
5537778b64 | ||
|
|
341d8e0cec | ||
|
|
9b5943192d | ||
|
|
bf56521a53 | ||
|
|
16a1af6a13 | ||
|
|
b8640666d7 | ||
|
|
0528a6fb3b | ||
|
|
5511871442 | ||
|
|
486e13a93b | ||
|
|
759cafb817 | ||
|
|
bd788ae303 | ||
|
|
bb8a0d987f | ||
|
|
92cc84e692 | ||
|
|
03abaf6059 | ||
|
|
6bed30e175 | ||
|
|
9f2cc28fef | ||
|
|
fdd5b866b5 | ||
|
|
4ebb928400 | ||
|
|
4522a8a7b0 | ||
|
|
14813e5c76 | ||
|
|
c67d299984 |
106
.github/workflows/release.yml
vendored
106
.github/workflows/release.yml
vendored
@@ -14,19 +14,19 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# - name: Bump version
|
||||
# run: >-
|
||||
# bin/bump_version.py
|
||||
- name: Bump version
|
||||
run: >-
|
||||
bin/bump_version.py
|
||||
|
||||
# - name: Commit updated version.py
|
||||
# id: commit_updated
|
||||
# run: |
|
||||
# git config --global user.name 'github-actions'
|
||||
# git config --global user.email 'bot@noreply.github.com'
|
||||
# git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
|
||||
# git add setup.py
|
||||
# git commit -m "bump version" && git push || echo "No changes to commit"
|
||||
# git log -n 1 --pretty=format:"%H" | tail -n 1 | awk '{print "::set-output name=sha::"$0}'
|
||||
- name: Commit updated version.py
|
||||
id: commit_updated
|
||||
run: |
|
||||
git config --global user.name 'github-actions'
|
||||
git config --global user.email 'bot@noreply.github.com'
|
||||
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
|
||||
git add setup.py
|
||||
git commit -m "bump version" && git push || echo "No changes to commit"
|
||||
git log -n 1 --pretty=format:"%H" | tail -n 1 | awk '{print "::set-output name=sha::"$0}'
|
||||
|
||||
- name: Get version
|
||||
id: get_version
|
||||
@@ -74,51 +74,51 @@ jobs:
|
||||
user: __token__
|
||||
password: ${{ secrets.PYPI_API_TOKEN }}
|
||||
|
||||
build-and-publish-mac:
|
||||
runs-on: macos-latest
|
||||
needs: release_create
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ needs.release_create.outputs.new_sha }}
|
||||
# build-and-publish-mac:
|
||||
# runs-on: macos-latest
|
||||
# needs: release_create
|
||||
# steps:
|
||||
# - name: Checkout
|
||||
# uses: actions/checkout@v3
|
||||
# with:
|
||||
# ref: ${{ needs.release_create.outputs.new_sha }}
|
||||
|
||||
- name: Set up Python 3.9
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.9
|
||||
# - name: Set up Python 3.9
|
||||
# uses: actions/setup-python@v2
|
||||
# with:
|
||||
# python-version: 3.9
|
||||
|
||||
- name: Setup code signing
|
||||
env:
|
||||
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
|
||||
MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
|
||||
MACOS_KEYCHAIN_PASSWORD: ${{ secrets.MACOS_KEYCHAIN_PASSWORD }}
|
||||
run: |
|
||||
echo $MACOS_CERTIFICATE | base64 --decode > certificate.p12
|
||||
security create-keychain -p "$MACOS_KEYCHAIN_PASSWORD" meshtastic.keychain
|
||||
security default-keychain -s meshtastic.keychain
|
||||
security unlock-keychain -p "$MACOS_KEYCHAIN_PASSWORD" meshtastic.keychain
|
||||
security import certificate.p12 -k meshtastic.keychain -P "$MACOS_CERTIFICATE_PWD" -T /usr/bin/codesign
|
||||
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$MACOS_KEYCHAIN_PASSWORD" meshtastic.keychain
|
||||
# - name: Setup code signing
|
||||
# env:
|
||||
# MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
|
||||
# MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
|
||||
# MACOS_KEYCHAIN_PASSWORD: ${{ secrets.MACOS_KEYCHAIN_PASSWORD }}
|
||||
# run: |
|
||||
# echo $MACOS_CERTIFICATE | base64 --decode > certificate.p12
|
||||
# security create-keychain -p "$MACOS_KEYCHAIN_PASSWORD" meshtastic.keychain
|
||||
# security default-keychain -s meshtastic.keychain
|
||||
# security unlock-keychain -p "$MACOS_KEYCHAIN_PASSWORD" meshtastic.keychain
|
||||
# security import certificate.p12 -k meshtastic.keychain -P "$MACOS_CERTIFICATE_PWD" -T /usr/bin/codesign
|
||||
# security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$MACOS_KEYCHAIN_PASSWORD" meshtastic.keychain
|
||||
|
||||
- name: Build
|
||||
env:
|
||||
MACOS_SIGNING_IDENTITY: ${{ secrets.MACOS_SIGNING_IDENTITY }}
|
||||
run: |
|
||||
pip install pyinstaller
|
||||
pip install -r requirements.txt
|
||||
pip install .
|
||||
pyinstaller -F -n meshtastic --collect-all meshtastic --codesign-identity "$MACOS_SIGNING_IDENTITY" meshtastic/__main__.py
|
||||
# - name: Build
|
||||
# env:
|
||||
# MACOS_SIGNING_IDENTITY: ${{ secrets.MACOS_SIGNING_IDENTITY }}
|
||||
# run: |
|
||||
# pip install pyinstaller
|
||||
# pip install -r requirements.txt
|
||||
# pip install .
|
||||
# pyinstaller -F -n meshtastic --collect-all meshtastic --codesign-identity "$MACOS_SIGNING_IDENTITY" meshtastic/__main__.py
|
||||
|
||||
- name: Add mac to release
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ needs.release_create.outputs.upload_url }}
|
||||
asset_path: dist/meshtastic
|
||||
asset_name: meshtastic_mac
|
||||
asset_content_type: application/zip
|
||||
# - name: Add mac to release
|
||||
# uses: actions/upload-release-asset@v1
|
||||
# env:
|
||||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# with:
|
||||
# upload_url: ${{ needs.release_create.outputs.upload_url }}
|
||||
# asset_path: dist/meshtastic
|
||||
# asset_name: meshtastic_mac
|
||||
# asset_content_type: application/zip
|
||||
|
||||
build-and-publish-ubuntu:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -9,7 +9,6 @@ import platform
|
||||
import sys
|
||||
import time
|
||||
|
||||
import pkg_resources
|
||||
import pyqrcode
|
||||
import yaml
|
||||
from google.protobuf.json_format import MessageToDict
|
||||
@@ -18,6 +17,7 @@ from pubsub import pub
|
||||
import meshtastic.test
|
||||
import meshtastic.util
|
||||
from meshtastic import channel_pb2, config_pb2, portnums_pb2, remote_hardware
|
||||
from meshtastic.version import get_active_version
|
||||
from meshtastic.__init__ import BROADCAST_ADDR
|
||||
from meshtastic.ble_interface import BLEInterface
|
||||
from meshtastic.globals import Globals
|
||||
@@ -135,7 +135,7 @@ def splitCompoundName(comp_name):
|
||||
return name
|
||||
|
||||
|
||||
def setPref(config, comp_name, valStr):
|
||||
def setPref(config, comp_name, valStr) -> bool:
|
||||
"""Set a channel or preferences value"""
|
||||
|
||||
name = splitCompoundName(comp_name)
|
||||
@@ -597,6 +597,12 @@ def onConnected(interface):
|
||||
# handle changing channels
|
||||
|
||||
if args.ch_add:
|
||||
channelIndex = our_globals.get_channel_index()
|
||||
if channelIndex is not None:
|
||||
# Since we set the channel index after adding a channel, don't allow --ch-index
|
||||
meshtastic.util.our_exit(
|
||||
"Warning: '--ch-add' and '--ch-index' are incompatible. Channel not added."
|
||||
)
|
||||
closeNow = True
|
||||
if len(args.ch_add) > 10:
|
||||
meshtastic.util.our_exit(
|
||||
@@ -620,6 +626,9 @@ def onConnected(interface):
|
||||
ch.role = channel_pb2.Channel.Role.SECONDARY
|
||||
print(f"Writing modified channels to device")
|
||||
n.writeChannel(ch.index)
|
||||
if channelIndex is None:
|
||||
print(f"Setting newly-added channel's {ch.index} as '--ch-index' for further modifications")
|
||||
our_globals.set_channel_index(ch.index)
|
||||
|
||||
if args.ch_del:
|
||||
closeNow = True
|
||||
@@ -690,9 +699,29 @@ def onConnected(interface):
|
||||
# Handle the channel settings
|
||||
for pref in args.ch_set or []:
|
||||
if pref[0] == "psk":
|
||||
found = True
|
||||
ch.settings.psk = meshtastic.util.fromPSK(pref[1])
|
||||
else:
|
||||
setPref(ch.settings, pref[0], pref[1])
|
||||
found = setPref(ch.settings, pref[0], pref[1])
|
||||
if not found:
|
||||
category_settings = ['module_settings']
|
||||
print(
|
||||
f"{ch.settings.__class__.__name__} does not have an attribute {pref[0]}."
|
||||
)
|
||||
print("Choices are...")
|
||||
for field in ch.settings.DESCRIPTOR.fields:
|
||||
if field.name not in category_settings:
|
||||
print(f"{field.name}")
|
||||
else:
|
||||
print(f"{field.name}:")
|
||||
config = ch.settings.DESCRIPTOR.fields_by_name.get(field.name)
|
||||
names = []
|
||||
for sub_field in config.message_type.fields:
|
||||
tmp_name = f"{field.name}.{sub_field.name}"
|
||||
names.append(tmp_name)
|
||||
for temp_name in sorted(names):
|
||||
print(f" {temp_name}")
|
||||
|
||||
enable = True # If we set any pref, assume the user wants to enable the channel
|
||||
|
||||
if enable:
|
||||
@@ -984,6 +1013,16 @@ def common():
|
||||
message += " After running that command, log out and re-login for it to take effect.\n"
|
||||
message += f"Error was:{ex}"
|
||||
meshtastic.util.our_exit(message)
|
||||
if client.devPath is None:
|
||||
try:
|
||||
client = meshtastic.tcp_interface.TCPInterface(
|
||||
"localhost", debugOut=logfile, noProto=args.noproto
|
||||
)
|
||||
except Exception as ex:
|
||||
meshtastic.util.our_exit(
|
||||
f"Error connecting to localhost:{ex}", 1
|
||||
)
|
||||
|
||||
|
||||
# We assume client is fully connected now
|
||||
onConnected(client)
|
||||
@@ -1019,7 +1058,7 @@ def initParser():
|
||||
|
||||
parser.add_argument(
|
||||
"--port",
|
||||
help="The port the Meshtastic device is connected to, i.e. /dev/ttyUSB0. If unspecified, we'll try to find it.",
|
||||
help="The port the Meshtastic device is connected to, i.e. /dev/ttyUSB0.",
|
||||
default=None,
|
||||
)
|
||||
|
||||
@@ -1221,7 +1260,7 @@ def initParser():
|
||||
help="Request telemetry from a node. "
|
||||
"You need pass the destination ID as argument with '--dest'. "
|
||||
"For repeaters, the nodeNum is required.",
|
||||
action="store_true",
|
||||
action="store_true",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
@@ -1360,7 +1399,7 @@ def initParser():
|
||||
|
||||
parser.set_defaults(deprecated=None)
|
||||
|
||||
the_version = pkg_resources.get_distribution("meshtastic").version
|
||||
the_version = get_active_version()
|
||||
parser.add_argument("--version", action="version", version=f"{the_version}")
|
||||
|
||||
parser.add_argument(
|
||||
@@ -1377,7 +1416,9 @@ def initParser():
|
||||
def main():
|
||||
"""Perform command line meshtastic operations"""
|
||||
our_globals = Globals.getInstance()
|
||||
parser = argparse.ArgumentParser()
|
||||
parser = argparse.ArgumentParser(
|
||||
epilog="If neither --port nor --host are specified, we search for a compatible serial device, "
|
||||
"and if none is found, then attempt a TCP connection to localhost.")
|
||||
our_globals.set_parser(parser)
|
||||
initParser()
|
||||
common()
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
import logging
|
||||
import time
|
||||
import struct
|
||||
import asyncio
|
||||
from threading import Thread, Event
|
||||
from bleak import BleakScanner, BleakClient
|
||||
|
||||
from meshtastic.mesh_interface import MeshInterface
|
||||
from meshtastic.util import our_exit
|
||||
from bleak import BleakScanner, BleakClient
|
||||
import asyncio
|
||||
|
||||
|
||||
SERVICE_UUID = "6ba1b218-15a8-461f-9fa8-5dcae273eafd"
|
||||
TORADIO_UUID = "f75c76d2-129e-4dad-a1dd-7866124401e7"
|
||||
@@ -17,13 +17,14 @@ FROMNUM_UUID = "ed9da18c-a800-4f66-a670-aa7547e34453"
|
||||
|
||||
|
||||
class BLEInterface(MeshInterface):
|
||||
"""MeshInterface using BLE to connect to devices"""
|
||||
class BLEError(Exception):
|
||||
"""An exception class for BLE errors"""
|
||||
def __init__(self, message):
|
||||
self.message = message
|
||||
super().__init__(self.message)
|
||||
|
||||
|
||||
class BLEState():
|
||||
class BLEState(): # pylint: disable=C0115
|
||||
THREADS = False
|
||||
BLE = False
|
||||
MESH = False
|
||||
@@ -60,7 +61,7 @@ class BLEInterface(MeshInterface):
|
||||
MeshInterface.__init__(self, debugOut = debugOut, noProto = noProto)
|
||||
self._startConfig()
|
||||
if not self.noProto:
|
||||
self._waitConnected()
|
||||
self._waitConnected(timeout = 60.0)
|
||||
self.waitForConfig()
|
||||
self.state.MESH = True
|
||||
logging.debug("Mesh init finished")
|
||||
@@ -69,13 +70,14 @@ class BLEInterface(MeshInterface):
|
||||
self.client.start_notify(FROMNUM_UUID, self.from_num_handler)
|
||||
|
||||
|
||||
async def from_num_handler(self, _, b):
|
||||
async def from_num_handler(self, _, b): # pylint: disable=C0116
|
||||
from_num = struct.unpack('<I', bytes(b))[0]
|
||||
logging.debug(f"FROMNUM notify: {from_num}")
|
||||
self.should_read = True
|
||||
|
||||
|
||||
def scan(self):
|
||||
"Scan for available BLE devices"
|
||||
with BLEClient() as client:
|
||||
return [
|
||||
(x[0], x[1]) for x in (client.discover(
|
||||
@@ -86,12 +88,15 @@ class BLEInterface(MeshInterface):
|
||||
|
||||
|
||||
def find_device(self, address):
|
||||
"Find a device by address"
|
||||
meshtastic_devices = self.scan()
|
||||
|
||||
addressed_devices = list(filter(lambda x: address == x[1].local_name or address == x[0].name, meshtastic_devices))
|
||||
addressed_devices = list(filter(lambda x: address in (x[1].local_name, x[0].name), meshtastic_devices))
|
||||
# If nothing is found try on the address
|
||||
if len(addressed_devices) == 0:
|
||||
addressed_devices = list(filter(lambda x: BLEInterface._sanitize_address(address) == BLEInterface._sanitize_address(x[0].address), meshtastic_devices))
|
||||
addressed_devices = list(filter(
|
||||
lambda x: BLEInterface._sanitize_address(address) == BLEInterface._sanitize_address(x[0].address),
|
||||
meshtastic_devices))
|
||||
|
||||
if len(addressed_devices) == 0:
|
||||
raise BLEInterface.BLEError(f"No Meshtastic BLE peripheral with identifier or address '{address}' found. Try --ble-scan to find it.")
|
||||
@@ -99,7 +104,8 @@ class BLEInterface(MeshInterface):
|
||||
raise BLEInterface.BLEError(f"More than one Meshtastic BLE peripheral with identifier or address '{address}' found.")
|
||||
return addressed_devices[0][0]
|
||||
|
||||
def _sanitize_address(address):
|
||||
def _sanitize_address(address): # pylint: disable=E0213
|
||||
"Standardize BLE address by removing extraneous characters and lowercasing"
|
||||
return address \
|
||||
.replace("-", "") \
|
||||
.replace("_", "") \
|
||||
@@ -107,6 +113,7 @@ class BLEInterface(MeshInterface):
|
||||
.lower()
|
||||
|
||||
def connect(self, address):
|
||||
"Connect to a device by address"
|
||||
device = self.find_device(address)
|
||||
client = BLEClient(device.address)
|
||||
client.connect()
|
||||
@@ -124,9 +131,14 @@ class BLEInterface(MeshInterface):
|
||||
while self._receiveThread_started.is_set():
|
||||
if self.should_read:
|
||||
self.should_read = False
|
||||
retries = 0
|
||||
while True:
|
||||
b = bytes(self.client.read_gatt_char(FROMRADIO_UUID))
|
||||
if not b:
|
||||
if retries < 5:
|
||||
time.sleep(0.1)
|
||||
retries += 1
|
||||
continue
|
||||
break
|
||||
logging.debug(f"FROMRADIO read: {b.hex()}")
|
||||
self._handleFromRadio(b)
|
||||
@@ -151,13 +163,14 @@ class BLEInterface(MeshInterface):
|
||||
if self.state.THREADS:
|
||||
self._receiveThread_started.clear()
|
||||
self._receiveThread_stopped.wait(5)
|
||||
|
||||
|
||||
if self.state.BLE:
|
||||
self.client.disconnect()
|
||||
self.client.close()
|
||||
|
||||
|
||||
class BLEClient():
|
||||
"""Client for managing connection to a BLE device"""
|
||||
def __init__(self, address = None, **kwargs):
|
||||
self._eventThread = Thread(target = self._run_event_loop)
|
||||
self._eventThread_started = Event()
|
||||
@@ -172,47 +185,46 @@ class BLEClient():
|
||||
self.bleak_client = BleakClient(address, **kwargs)
|
||||
|
||||
|
||||
def discover(self, **kwargs):
|
||||
def discover(self, **kwargs): # pylint: disable=C0116
|
||||
return self.async_await(BleakScanner.discover(**kwargs))
|
||||
|
||||
def pair(self, **kwargs):
|
||||
def pair(self, **kwargs): # pylint: disable=C0116
|
||||
return self.async_await(self.bleak_client.pair(**kwargs))
|
||||
|
||||
def connect(self, **kwargs):
|
||||
def connect(self, **kwargs): # pylint: disable=C0116
|
||||
return self.async_await(self.bleak_client.connect(**kwargs))
|
||||
|
||||
def disconnect(self, **kwargs):
|
||||
def disconnect(self, **kwargs): # pylint: disable=C0116
|
||||
self.async_await(self.bleak_client.disconnect(**kwargs))
|
||||
|
||||
def read_gatt_char(self, *args, **kwargs):
|
||||
def read_gatt_char(self, *args, **kwargs): # pylint: disable=C0116
|
||||
return self.async_await(self.bleak_client.read_gatt_char(*args, **kwargs))
|
||||
|
||||
def write_gatt_char(self, *args, **kwargs):
|
||||
def write_gatt_char(self, *args, **kwargs): # pylint: disable=C0116
|
||||
self.async_await(self.bleak_client.write_gatt_char(*args, **kwargs))
|
||||
|
||||
def start_notify(self, *args, **kwargs):
|
||||
def start_notify(self, *args, **kwargs): # pylint: disable=C0116
|
||||
self.async_await(self.bleak_client.start_notify(*args, **kwargs))
|
||||
|
||||
|
||||
def close(self):
|
||||
def close(self): # pylint: disable=C0116
|
||||
self.async_run(self._stop_event_loop())
|
||||
self._eventThread_stopped.wait(5)
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
def __exit__(self, _type, _value, _traceback):
|
||||
self.close()
|
||||
|
||||
|
||||
def async_await(self, coro, timeout = None):
|
||||
def async_await(self, coro, timeout = None): # pylint: disable=C0116
|
||||
return self.async_run(coro).result(timeout)
|
||||
|
||||
def async_run(self, coro):
|
||||
def async_run(self, coro): # pylint: disable=C0116
|
||||
return asyncio.run_coroutine_threadsafe(coro, self._eventLoop)
|
||||
|
||||
def _run_event_loop(self):
|
||||
self._eventLoop = asyncio.new_event_loop()
|
||||
# I don't know if the event loop can be initialized in __init__ so silencing pylint
|
||||
self._eventLoop = asyncio.new_event_loop() # pylint: disable=W0201
|
||||
self._eventThread_started.set()
|
||||
try:
|
||||
self._eventLoop.run_forever()
|
||||
|
||||
@@ -14,7 +14,7 @@ _sym_db = _symbol_database.Default()
|
||||
from meshtastic import localonly_pb2 as meshtastic_dot_localonly__pb2
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1bmeshtastic/clientonly.proto\x1a\x1ameshtastic/localonly.proto\"\xf7\x01\n\rDeviceProfile\x12\x16\n\tlong_name\x18\x01 \x01(\tH\x00\x88\x01\x01\x12\x17\n\nshort_name\x18\x02 \x01(\tH\x01\x88\x01\x01\x12\x18\n\x0b\x63hannel_url\x18\x03 \x01(\tH\x02\x88\x01\x01\x12!\n\x06\x63onfig\x18\x04 \x01(\x0b\x32\x0c.LocalConfigH\x03\x88\x01\x01\x12.\n\rmodule_config\x18\x05 \x01(\x0b\x32\x12.LocalModuleConfigH\x04\x88\x01\x01\x42\x0c\n\n_long_nameB\r\n\x0b_short_nameB\x0e\n\x0c_channel_urlB\t\n\x07_configB\x10\n\x0e_module_config\"\x0b\n\tHeartbeatBe\n\x13\x63om.geeksville.meshB\x10\x43lientOnlyProtosZ\"github.com/meshtastic/go/generated\xaa\x02\x14Meshtastic.Protobufs\xba\x02\x00\x62\x06proto3')
|
||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1bmeshtastic/clientonly.proto\x1a\x1ameshtastic/localonly.proto\"\xf7\x01\n\rDeviceProfile\x12\x16\n\tlong_name\x18\x01 \x01(\tH\x00\x88\x01\x01\x12\x17\n\nshort_name\x18\x02 \x01(\tH\x01\x88\x01\x01\x12\x18\n\x0b\x63hannel_url\x18\x03 \x01(\tH\x02\x88\x01\x01\x12!\n\x06\x63onfig\x18\x04 \x01(\x0b\x32\x0c.LocalConfigH\x03\x88\x01\x01\x12.\n\rmodule_config\x18\x05 \x01(\x0b\x32\x12.LocalModuleConfigH\x04\x88\x01\x01\x42\x0c\n\n_long_nameB\r\n\x0b_short_nameB\x0e\n\x0c_channel_urlB\t\n\x07_configB\x10\n\x0e_module_configBe\n\x13\x63om.geeksville.meshB\x10\x43lientOnlyProtosZ\"github.com/meshtastic/go/generated\xaa\x02\x14Meshtastic.Protobufs\xba\x02\x00\x62\x06proto3')
|
||||
|
||||
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
|
||||
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'meshtastic.clientonly_pb2', globals())
|
||||
@@ -24,6 +24,4 @@ if _descriptor._USE_C_DESCRIPTORS == False:
|
||||
DESCRIPTOR._serialized_options = b'\n\023com.geeksville.meshB\020ClientOnlyProtosZ\"github.com/meshtastic/go/generated\252\002\024Meshtastic.Protobufs\272\002\000'
|
||||
_DEVICEPROFILE._serialized_start=60
|
||||
_DEVICEPROFILE._serialized_end=307
|
||||
_HEARTBEAT._serialized_start=309
|
||||
_HEARTBEAT._serialized_end=320
|
||||
# @@protoc_insertion_point(module_scope)
|
||||
|
||||
@@ -18,7 +18,7 @@ from meshtastic import telemetry_pb2 as meshtastic_dot_telemetry__pb2
|
||||
from meshtastic import module_config_pb2 as meshtastic_dot_module__config__pb2
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1bmeshtastic/deviceonly.proto\x1a\x18meshtastic/channel.proto\x1a\x1ameshtastic/localonly.proto\x1a\x15meshtastic/mesh.proto\x1a\x1ameshtastic/telemetry.proto\x1a\x1emeshtastic/module_config.proto\"\xc6\x02\n\x0b\x44\x65viceState\x12\x1c\n\x07my_node\x18\x02 \x01(\x0b\x32\x0b.MyNodeInfo\x12\x14\n\x05owner\x18\x03 \x01(\x0b\x32\x05.User\x12\"\n\rreceive_queue\x18\x05 \x03(\x0b\x32\x0b.MeshPacket\x12\x0f\n\x07version\x18\x08 \x01(\r\x12$\n\x0frx_text_message\x18\x07 \x01(\x0b\x32\x0b.MeshPacket\x12\x0f\n\x07no_save\x18\t \x01(\x08\x12\x15\n\rdid_gps_reset\x18\x0b \x01(\x08\x12 \n\x0brx_waypoint\x18\x0c \x01(\x0b\x32\x0b.MeshPacket\x12\x39\n\x19node_remote_hardware_pins\x18\r \x03(\x0b\x32\x16.NodeRemoteHardwarePin\x12#\n\x0cnode_db_lite\x18\x0e \x03(\x0b\x32\r.NodeInfoLite\"\xd0\x01\n\x0cNodeInfoLite\x12\x0b\n\x03num\x18\x01 \x01(\r\x12\x13\n\x04user\x18\x02 \x01(\x0b\x32\x05.User\x12\x1f\n\x08position\x18\x03 \x01(\x0b\x32\r.PositionLite\x12\x0b\n\x03snr\x18\x04 \x01(\x02\x12\x12\n\nlast_heard\x18\x05 \x01(\x07\x12&\n\x0e\x64\x65vice_metrics\x18\x06 \x01(\x0b\x32\x0e.DeviceMetrics\x12\x0f\n\x07\x63hannel\x18\x07 \x01(\r\x12\x10\n\x08via_mqtt\x18\x08 \x01(\x08\x12\x11\n\thops_away\x18\t \x01(\r\"\x85\x01\n\x0cPositionLite\x12\x12\n\nlatitude_i\x18\x01 \x01(\x0f\x12\x13\n\x0blongitude_i\x18\x02 \x01(\x0f\x12\x10\n\x08\x61ltitude\x18\x03 \x01(\x05\x12\x0c\n\x04time\x18\x04 \x01(\x07\x12,\n\x0flocation_source\x18\x05 \x01(\x0e\x32\x13.Position.LocSource\":\n\x0b\x43hannelFile\x12\x1a\n\x08\x63hannels\x18\x01 \x03(\x0b\x32\x08.Channel\x12\x0f\n\x07version\x18\x02 \x01(\r\"\xf6\x01\n\x08OEMStore\x12\x16\n\x0eoem_icon_width\x18\x01 \x01(\r\x12\x17\n\x0foem_icon_height\x18\x02 \x01(\r\x12\x15\n\roem_icon_bits\x18\x03 \x01(\x0c\x12\x1e\n\x08oem_font\x18\x04 \x01(\x0e\x32\x0c.ScreenFonts\x12\x10\n\x08oem_text\x18\x05 \x01(\t\x12\x13\n\x0boem_aes_key\x18\x06 \x01(\x0c\x12&\n\x10oem_local_config\x18\x07 \x01(\x0b\x32\x0c.LocalConfig\x12\x33\n\x17oem_local_module_config\x18\x08 \x01(\x0b\x32\x12.LocalModuleConfig\"J\n\x15NodeRemoteHardwarePin\x12\x10\n\x08node_num\x18\x01 \x01(\r\x12\x1f\n\x03pin\x18\x02 \x01(\x0b\x32\x12.RemoteHardwarePin*>\n\x0bScreenFonts\x12\x0e\n\nFONT_SMALL\x10\x00\x12\x0f\n\x0b\x46ONT_MEDIUM\x10\x01\x12\x0e\n\nFONT_LARGE\x10\x02\x42_\n\x13\x63om.geeksville.meshB\nDeviceOnlyZ\"github.com/meshtastic/go/generated\xaa\x02\x14Meshtastic.Protobufs\xba\x02\x00\x62\x06proto3')
|
||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1bmeshtastic/deviceonly.proto\x1a\x18meshtastic/channel.proto\x1a\x1ameshtastic/localonly.proto\x1a\x15meshtastic/mesh.proto\x1a\x1ameshtastic/telemetry.proto\x1a\x1emeshtastic/module_config.proto\"\xca\x02\n\x0b\x44\x65viceState\x12\x1c\n\x07my_node\x18\x02 \x01(\x0b\x32\x0b.MyNodeInfo\x12\x14\n\x05owner\x18\x03 \x01(\x0b\x32\x05.User\x12\"\n\rreceive_queue\x18\x05 \x03(\x0b\x32\x0b.MeshPacket\x12\x0f\n\x07version\x18\x08 \x01(\r\x12$\n\x0frx_text_message\x18\x07 \x01(\x0b\x32\x0b.MeshPacket\x12\x13\n\x07no_save\x18\t \x01(\x08\x42\x02\x18\x01\x12\x15\n\rdid_gps_reset\x18\x0b \x01(\x08\x12 \n\x0brx_waypoint\x18\x0c \x01(\x0b\x32\x0b.MeshPacket\x12\x39\n\x19node_remote_hardware_pins\x18\r \x03(\x0b\x32\x16.NodeRemoteHardwarePin\x12#\n\x0cnode_db_lite\x18\x0e \x03(\x0b\x32\r.NodeInfoLite\"\xd0\x01\n\x0cNodeInfoLite\x12\x0b\n\x03num\x18\x01 \x01(\r\x12\x13\n\x04user\x18\x02 \x01(\x0b\x32\x05.User\x12\x1f\n\x08position\x18\x03 \x01(\x0b\x32\r.PositionLite\x12\x0b\n\x03snr\x18\x04 \x01(\x02\x12\x12\n\nlast_heard\x18\x05 \x01(\x07\x12&\n\x0e\x64\x65vice_metrics\x18\x06 \x01(\x0b\x32\x0e.DeviceMetrics\x12\x0f\n\x07\x63hannel\x18\x07 \x01(\r\x12\x10\n\x08via_mqtt\x18\x08 \x01(\x08\x12\x11\n\thops_away\x18\t \x01(\r\"\x85\x01\n\x0cPositionLite\x12\x12\n\nlatitude_i\x18\x01 \x01(\x0f\x12\x13\n\x0blongitude_i\x18\x02 \x01(\x0f\x12\x10\n\x08\x61ltitude\x18\x03 \x01(\x05\x12\x0c\n\x04time\x18\x04 \x01(\x07\x12,\n\x0flocation_source\x18\x05 \x01(\x0e\x32\x13.Position.LocSource\":\n\x0b\x43hannelFile\x12\x1a\n\x08\x63hannels\x18\x01 \x03(\x0b\x32\x08.Channel\x12\x0f\n\x07version\x18\x02 \x01(\r\"\xf6\x01\n\x08OEMStore\x12\x16\n\x0eoem_icon_width\x18\x01 \x01(\r\x12\x17\n\x0foem_icon_height\x18\x02 \x01(\r\x12\x15\n\roem_icon_bits\x18\x03 \x01(\x0c\x12\x1e\n\x08oem_font\x18\x04 \x01(\x0e\x32\x0c.ScreenFonts\x12\x10\n\x08oem_text\x18\x05 \x01(\t\x12\x13\n\x0boem_aes_key\x18\x06 \x01(\x0c\x12&\n\x10oem_local_config\x18\x07 \x01(\x0b\x32\x0c.LocalConfig\x12\x33\n\x17oem_local_module_config\x18\x08 \x01(\x0b\x32\x12.LocalModuleConfig\"J\n\x15NodeRemoteHardwarePin\x12\x10\n\x08node_num\x18\x01 \x01(\r\x12\x1f\n\x03pin\x18\x02 \x01(\x0b\x32\x12.RemoteHardwarePin*>\n\x0bScreenFonts\x12\x0e\n\nFONT_SMALL\x10\x00\x12\x0f\n\x0b\x46ONT_MEDIUM\x10\x01\x12\x0e\n\nFONT_LARGE\x10\x02\x42_\n\x13\x63om.geeksville.meshB\nDeviceOnlyZ\"github.com/meshtastic/go/generated\xaa\x02\x14Meshtastic.Protobufs\xba\x02\x00\x62\x06proto3')
|
||||
|
||||
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
|
||||
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'meshtastic.deviceonly_pb2', globals())
|
||||
@@ -26,18 +26,20 @@ if _descriptor._USE_C_DESCRIPTORS == False:
|
||||
|
||||
DESCRIPTOR._options = None
|
||||
DESCRIPTOR._serialized_options = b'\n\023com.geeksville.meshB\nDeviceOnlyZ\"github.com/meshtastic/go/generated\252\002\024Meshtastic.Protobufs\272\002\000'
|
||||
_SCREENFONTS._serialized_start=1229
|
||||
_SCREENFONTS._serialized_end=1291
|
||||
_DEVICESTATE.fields_by_name['no_save']._options = None
|
||||
_DEVICESTATE.fields_by_name['no_save']._serialized_options = b'\030\001'
|
||||
_SCREENFONTS._serialized_start=1233
|
||||
_SCREENFONTS._serialized_end=1295
|
||||
_DEVICESTATE._serialized_start=169
|
||||
_DEVICESTATE._serialized_end=495
|
||||
_NODEINFOLITE._serialized_start=498
|
||||
_NODEINFOLITE._serialized_end=706
|
||||
_POSITIONLITE._serialized_start=709
|
||||
_POSITIONLITE._serialized_end=842
|
||||
_CHANNELFILE._serialized_start=844
|
||||
_CHANNELFILE._serialized_end=902
|
||||
_OEMSTORE._serialized_start=905
|
||||
_OEMSTORE._serialized_end=1151
|
||||
_NODEREMOTEHARDWAREPIN._serialized_start=1153
|
||||
_NODEREMOTEHARDWAREPIN._serialized_end=1227
|
||||
_DEVICESTATE._serialized_end=499
|
||||
_NODEINFOLITE._serialized_start=502
|
||||
_NODEINFOLITE._serialized_end=710
|
||||
_POSITIONLITE._serialized_start=713
|
||||
_POSITIONLITE._serialized_end=846
|
||||
_CHANNELFILE._serialized_start=848
|
||||
_CHANNELFILE._serialized_end=906
|
||||
_OEMSTORE._serialized_start=909
|
||||
_OEMSTORE._serialized_end=1155
|
||||
_NODEREMOTEHARDWAREPIN._serialized_start=1157
|
||||
_NODEREMOTEHARDWAREPIN._serialized_end=1231
|
||||
# @@protoc_insertion_point(module_scope)
|
||||
|
||||
@@ -24,7 +24,7 @@ class Globals:
|
||||
def __init__(self):
|
||||
"""Constructor for the Globals CLass"""
|
||||
if Globals.__instance is not None:
|
||||
raise Exception("This class is a singleton")
|
||||
raise Exception("This class is a singleton") # pylint: disable=W0719
|
||||
else:
|
||||
Globals.__instance = self
|
||||
self.args = None
|
||||
|
||||
@@ -23,7 +23,6 @@ from meshtastic.__init__ import (
|
||||
BROADCAST_ADDR,
|
||||
BROADCAST_NUM,
|
||||
LOCAL_ADDR,
|
||||
OUR_APP_VERSION,
|
||||
ResponseHandler,
|
||||
protocols,
|
||||
publishingThread,
|
||||
@@ -48,6 +47,12 @@ class MeshInterface:
|
||||
debugOut
|
||||
"""
|
||||
|
||||
class MeshInterfaceError(Exception):
|
||||
"""An exception class for general mesh interface errors"""
|
||||
def __init__(self, message):
|
||||
self.message = message
|
||||
super().__init__(self.message)
|
||||
|
||||
def __init__(self, debugOut=None, noProto=False):
|
||||
"""Constructor
|
||||
|
||||
@@ -152,13 +157,13 @@ class MeshInterface:
|
||||
)
|
||||
|
||||
rows = []
|
||||
if self.nodes:
|
||||
if self.nodesByNum:
|
||||
logging.debug(f"self.nodes:{self.nodes}")
|
||||
for node in self.nodes.values():
|
||||
for node in self.nodesByNum.values():
|
||||
if not includeSelf and node["num"] == self.localNode.nodeNum:
|
||||
continue
|
||||
|
||||
row = {"N": 0}
|
||||
row = {"N": 0, "User": f"UNK: {node['num']}", "ID": f"!{node['num']:x}"}
|
||||
|
||||
user = node.get("user")
|
||||
if user:
|
||||
@@ -314,7 +319,7 @@ class MeshInterface:
|
||||
f"mesh_pb2.Constants.DATA_PAYLOAD_LEN: {mesh_pb2.Constants.DATA_PAYLOAD_LEN}"
|
||||
)
|
||||
if len(data) > mesh_pb2.Constants.DATA_PAYLOAD_LEN:
|
||||
raise Exception("Data payload too big")
|
||||
raise MeshInterface.MeshInterfaceError("Data payload too big")
|
||||
|
||||
if (
|
||||
portNum == portnums_pb2.PortNum.UNKNOWN_APP
|
||||
@@ -440,7 +445,7 @@ class MeshInterface:
|
||||
destinationId = int(destinationId[1:], 16)
|
||||
else:
|
||||
destinationId = int(destinationId)
|
||||
|
||||
|
||||
self.sendData(
|
||||
r,
|
||||
destinationId=destinationId,
|
||||
@@ -469,7 +474,7 @@ class MeshInterface:
|
||||
)
|
||||
if telemetry.device_metrics.air_util_tx is not None:
|
||||
print(f"Transmit air utilization: {telemetry.device_metrics.air_util_tx:.2f}%")
|
||||
|
||||
|
||||
elif p["decoded"]["portnum"] == 'ROUTING_APP':
|
||||
if p["decoded"]["routing"]["errorReason"] == 'NO_RESPONSE':
|
||||
our_exit("No response from node. At least firmware 2.1.22 is required on the destination node.")
|
||||
@@ -543,25 +548,25 @@ class MeshInterface:
|
||||
and self.localNode.waitForConfig()
|
||||
)
|
||||
if not success:
|
||||
raise Exception("Timed out waiting for interface config")
|
||||
raise MeshInterface.MeshInterfaceError("Timed out waiting for interface config")
|
||||
|
||||
def waitForAckNak(self):
|
||||
"""Wait for the ack/nak"""
|
||||
success = self._timeout.waitForAckNak(self._acknowledgment)
|
||||
if not success:
|
||||
raise Exception("Timed out waiting for an acknowledgment")
|
||||
raise MeshInterface.MeshInterfaceError("Timed out waiting for an acknowledgment")
|
||||
|
||||
def waitForTraceRoute(self, waitFactor):
|
||||
"""Wait for trace route"""
|
||||
success = self._timeout.waitForTraceRoute(waitFactor, self._acknowledgment)
|
||||
if not success:
|
||||
raise Exception("Timed out waiting for traceroute")
|
||||
|
||||
raise MeshInterface.MeshInterfaceError("Timed out waiting for traceroute")
|
||||
|
||||
def waitForTelemetry(self):
|
||||
"""Wait for telemetry"""
|
||||
success = self._timeout.waitForTelemetry(self._acknowledgment)
|
||||
if not success:
|
||||
raise Exception("Timed out waiting for telemetry")
|
||||
raise MeshInterface.MeshInterfaceError("Timed out waiting for telemetry")
|
||||
|
||||
def getMyNodeInfo(self):
|
||||
"""Get info about my node."""
|
||||
@@ -596,7 +601,7 @@ class MeshInterface:
|
||||
and raise an exception"""
|
||||
if not self.noProto:
|
||||
if not self.isConnected.wait(timeout): # timeout after x seconds
|
||||
raise Exception("Timed out waiting for connection completion")
|
||||
raise MeshInterface.MeshInterfaceError("Timed out waiting for connection completion")
|
||||
|
||||
# If we failed while connecting, raise the connection to the client
|
||||
if self.failure:
|
||||
@@ -605,7 +610,7 @@ class MeshInterface:
|
||||
def _generatePacketId(self):
|
||||
"""Get a new unique packet ID"""
|
||||
if self.currentPacketId is None:
|
||||
raise Exception("Not connected yet, can not generate packet")
|
||||
raise MeshInterface.MeshInterfaceError("Not connected yet, can not generate packet")
|
||||
else:
|
||||
self.currentPacketId = (self.currentPacketId + 1) & 0xFFFFFFFF
|
||||
return self.currentPacketId
|
||||
@@ -774,7 +779,7 @@ class MeshInterface:
|
||||
failmsg = None
|
||||
|
||||
if failmsg:
|
||||
self.failure = Exception(failmsg)
|
||||
self.failure = MeshInterface.MeshInterfaceError(failmsg)
|
||||
self.isConnected.set() # let waitConnected return this exception
|
||||
self.close()
|
||||
|
||||
@@ -920,7 +925,7 @@ class MeshInterface:
|
||||
def _getOrCreateByNum(self, nodeNum):
|
||||
"""Given a nodenum find the NodeInfo in the DB (or create if necessary)"""
|
||||
if nodeNum == BROADCAST_NUM:
|
||||
raise Exception("Can not create/find nodenum by the broadcast num")
|
||||
raise MeshInterface.MeshInterfaceError("Can not create/find nodenum by the broadcast num")
|
||||
|
||||
if nodeNum in self.nodesByNum:
|
||||
return self.nodesByNum[nodeNum]
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -115,6 +115,7 @@ class Node:
|
||||
print(f"{str(camel_to_snake(field))}:\n{str(config_values)}")
|
||||
|
||||
def requestConfig(self, configType):
|
||||
"""Request the config from the node via admin message"""
|
||||
if self == self.iface.localNode:
|
||||
onResponse = None
|
||||
else:
|
||||
@@ -688,9 +689,6 @@ class Node:
|
||||
logging.debug(f"Received channel {stripnl(c)}")
|
||||
index = c.index
|
||||
|
||||
# for stress testing, we can always download all channels
|
||||
fastChannelDownload = True
|
||||
|
||||
if index >= 8 - 1:
|
||||
logging.debug("Finished downloading channels")
|
||||
|
||||
@@ -703,6 +701,7 @@ class Node:
|
||||
self._requestChannel(index + 1)
|
||||
|
||||
def onAckNak(self, p):
|
||||
"""Informative handler for ACK/NAK responses"""
|
||||
if p["decoded"]["routing"]["errorReason"] != "NONE":
|
||||
print(
|
||||
f'Received a NAK, error reason: {p["decoded"]["routing"]["errorReason"]}'
|
||||
|
||||
@@ -32,7 +32,8 @@ class SerialInterface(StreamInterface):
|
||||
ports = meshtastic.util.findPorts(True)
|
||||
logging.debug(f"ports:{ports}")
|
||||
if len(ports) == 0:
|
||||
meshtastic.util.our_exit("Warning: No Meshtastic devices detected.")
|
||||
print("No Serial Meshtastic device detected, attempting TCP connection on localhost.")
|
||||
return
|
||||
elif len(ports) > 1:
|
||||
message = "Warning: Multiple serial ports were detected so one serial port must be specified with the '--port'.\n"
|
||||
message += f" Ports detected:{ports}"
|
||||
|
||||
@@ -32,7 +32,7 @@ class StreamInterface(MeshInterface):
|
||||
"""
|
||||
|
||||
if not hasattr(self, "stream") and not noProto:
|
||||
raise Exception(
|
||||
raise Exception( # pylint: disable=W0719
|
||||
"StreamInterface is now abstract (to update existing code create SerialInterface instead)"
|
||||
)
|
||||
self._rxBuf = bytes() # empty
|
||||
|
||||
@@ -23,7 +23,7 @@ from meshtastic.__main__ import (
|
||||
tunnelMain,
|
||||
)
|
||||
|
||||
from ..channel_pb2 import Channel
|
||||
from ..channel_pb2 import Channel # pylint: disable=E0611
|
||||
|
||||
# from ..ble_interface import BLEInterface
|
||||
from ..node import Node
|
||||
@@ -388,7 +388,7 @@ def test_main_onConnected_exception(capsys):
|
||||
Globals.getInstance().set_args(sys.argv)
|
||||
|
||||
def throw_an_exception(junk):
|
||||
raise Exception("Fake exception.")
|
||||
raise Exception("Fake exception.") # pylint: disable=W0719
|
||||
|
||||
iface = MagicMock(autospec=SerialInterface)
|
||||
with patch("meshtastic.serial_interface.SerialInterface", return_value=iface):
|
||||
|
||||
@@ -7,7 +7,7 @@ from unittest.mock import MagicMock, patch
|
||||
import pytest
|
||||
|
||||
# from ..admin_pb2 import AdminMessage
|
||||
from ..channel_pb2 import Channel
|
||||
from ..channel_pb2 import Channel # pylint: disable=E0611
|
||||
from ..node import Node
|
||||
from ..serial_interface import SerialInterface
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@ def test_catchAndIgnore(caplog):
|
||||
"""Test catchAndIgnore() does not actually throw an exception, but just logs"""
|
||||
|
||||
def some_closure():
|
||||
raise Exception("foo")
|
||||
raise Exception("foo") # pylint: disable=W0719
|
||||
|
||||
with caplog.at_level(logging.DEBUG):
|
||||
catchAndIgnore("something", some_closure)
|
||||
|
||||
@@ -38,6 +38,12 @@ def onTunnelReceive(packet, interface): # pylint: disable=W0613
|
||||
class Tunnel:
|
||||
"""A TUN based IP tunnel over meshtastic"""
|
||||
|
||||
class TunnelError(Exception):
|
||||
"""An exception class for general tunnel errors"""
|
||||
def __init__(self, message):
|
||||
self.message = message
|
||||
super().__init__(self.message)
|
||||
|
||||
def __init__(self, iface, subnet="10.115", netmask="255.255.0.0"):
|
||||
"""
|
||||
Constructor
|
||||
@@ -47,19 +53,19 @@ class Tunnel:
|
||||
"""
|
||||
|
||||
if not iface:
|
||||
raise Exception("Tunnel() must have a interface")
|
||||
raise Tunnel.TunnelError("Tunnel() must have a interface")
|
||||
|
||||
if not subnet:
|
||||
raise Exception("Tunnel() must have a subnet")
|
||||
raise Tunnel.TunnelError("Tunnel() must have a subnet")
|
||||
|
||||
if not netmask:
|
||||
raise Exception("Tunnel() must have a netmask")
|
||||
raise Tunnel.TunnelError("Tunnel() must have a netmask")
|
||||
|
||||
self.iface = iface
|
||||
self.subnetPrefix = subnet
|
||||
|
||||
if platform.system() != "Linux":
|
||||
raise Exception("Tunnel() can only be run instantiated on a Linux system")
|
||||
raise Tunnel.TunnelError("Tunnel() can only be run instantiated on a Linux system")
|
||||
|
||||
our_globals = Globals.getInstance()
|
||||
our_globals.set_tunnelInstance(self)
|
||||
|
||||
@@ -12,12 +12,13 @@ import time
|
||||
import traceback
|
||||
from queue import Queue
|
||||
|
||||
import pkg_resources
|
||||
import packaging.version as pkg_version
|
||||
import requests
|
||||
import serial
|
||||
import serial.tools.list_ports
|
||||
|
||||
from meshtastic.supported_device import supported_devices
|
||||
from meshtastic.version import get_active_version
|
||||
|
||||
"""Some devices such as a seger jlink we never want to accidentally open"""
|
||||
blacklistVids = dict.fromkeys([0x1366])
|
||||
@@ -108,7 +109,7 @@ def stripnl(s):
|
||||
|
||||
def fixme(message):
|
||||
"""Raise an exception for things that needs to be fixed"""
|
||||
raise Exception(f"FIXME: {message}")
|
||||
raise Exception(f"FIXME: {message}") # pylint: disable=W0719
|
||||
|
||||
|
||||
def catchAndIgnore(reason, closure):
|
||||
@@ -192,7 +193,7 @@ class Timeout:
|
||||
return True
|
||||
time.sleep(self.sleepInterval)
|
||||
return False
|
||||
|
||||
|
||||
def waitForTelemetry(self, acknowledgment):
|
||||
"""Block until telemetry response is received. Returns True if telemetry response has been received."""
|
||||
self.reset()
|
||||
@@ -269,7 +270,7 @@ def support_info():
|
||||
print(f" Machine: {platform.uname().machine}")
|
||||
print(f" Encoding (stdin): {sys.stdin.encoding}")
|
||||
print(f" Encoding (stdout): {sys.stdout.encoding}")
|
||||
the_version = pkg_resources.get_distribution("meshtastic").version
|
||||
the_version = get_active_version()
|
||||
pypi_version = check_if_newer_version()
|
||||
if pypi_version:
|
||||
print(
|
||||
@@ -599,9 +600,15 @@ def check_if_newer_version():
|
||||
pypi_version = data["info"]["version"]
|
||||
except Exception:
|
||||
pass
|
||||
act_version = pkg_resources.get_distribution("meshtastic").version
|
||||
if pypi_version and pkg_resources.parse_version(
|
||||
pypi_version
|
||||
) <= pkg_resources.parse_version(act_version):
|
||||
act_version = get_active_version()
|
||||
|
||||
try:
|
||||
parsed_act_version = pkg_version.parse(act_version)
|
||||
parsed_pypi_version = pkg_version.parse(pypi_version)
|
||||
except pkg_version.InvalidVersion:
|
||||
return pypi_version
|
||||
|
||||
if parsed_pypi_version <= parsed_act_version:
|
||||
return None
|
||||
|
||||
return pypi_version
|
||||
|
||||
13
meshtastic/version.py
Normal file
13
meshtastic/version.py
Normal file
@@ -0,0 +1,13 @@
|
||||
"""Version lookup utilities, isolated for cleanliness"""
|
||||
import sys
|
||||
try:
|
||||
from importlib.metadata import version
|
||||
except:
|
||||
import pkg_resources
|
||||
|
||||
def get_active_version():
|
||||
"""Get the currently active version using importlib, or pkg_resources if we must"""
|
||||
if "importlib.metadata" in sys.modules:
|
||||
return version("meshtastic")
|
||||
else:
|
||||
return pkg_resources.get_distribution("meshtastic").version # pylint: disable=E0601
|
||||
Submodule protobufs updated: 6942175394...556e49ba61
@@ -19,3 +19,4 @@ pytap2
|
||||
pdoc3
|
||||
pypubsub
|
||||
bleak
|
||||
packaging
|
||||
|
||||
Reference in New Issue
Block a user