Skip to content

Commit c580df1

Browse files
committed
Merge 'master' into 'bugfix-466-yaml-import'.
2 parents 590b60f + b280d0b commit c580df1

80 files changed

Lines changed: 10864 additions & 1231 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,19 @@ jobs:
3434
which meshtastic
3535
meshtastic --version
3636
- name: Run pylint
37-
run: pylint meshtastic examples/ --ignore-patterns ".*_pb2.py$"
37+
run: pylint meshtastic examples/ --ignore-patterns ".*_pb2.pyi?$"
38+
- name: Check types with mypy
39+
run: mypy meshtastic/
3840
- name: Run tests with pytest
3941
run: pytest --cov=meshtastic
4042
- name: Generate coverage report
4143
run: |
4244
pytest --cov=meshtastic --cov-report=xml
4345
- name: Upload coverage to Codecov
44-
uses: codecov/codecov-action@v2
46+
uses: codecov/codecov-action@v4
4547
with:
4648
token: ${{ secrets.CODECOV_TOKEN }}
49+
env_vars: OS, PYTHON
4750
files: ./coverage.xml
4851
flags: unittests
4952
name: codecov-umbrella

.github/workflows/release.yml

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -74,51 +74,51 @@ jobs:
7474
user: __token__
7575
password: ${{ secrets.PYPI_API_TOKEN }}
7676

77-
build-and-publish-mac:
78-
runs-on: macos-latest
79-
needs: release_create
80-
steps:
81-
- name: Checkout
82-
uses: actions/checkout@v3
83-
with:
84-
ref: ${{ needs.release_create.outputs.new_sha }}
85-
86-
- name: Set up Python 3.9
87-
uses: actions/setup-python@v2
88-
with:
89-
python-version: 3.9
90-
91-
- name: Setup code signing
92-
env:
93-
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
94-
MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
95-
MACOS_KEYCHAIN_PASSWORD: ${{ secrets.MACOS_KEYCHAIN_PASSWORD }}
96-
run: |
97-
echo $MACOS_CERTIFICATE | base64 --decode > certificate.p12
98-
security create-keychain -p "$MACOS_KEYCHAIN_PASSWORD" meshtastic.keychain
99-
security default-keychain -s meshtastic.keychain
100-
security unlock-keychain -p "$MACOS_KEYCHAIN_PASSWORD" meshtastic.keychain
101-
security import certificate.p12 -k meshtastic.keychain -P "$MACOS_CERTIFICATE_PWD" -T /usr/bin/codesign
102-
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$MACOS_KEYCHAIN_PASSWORD" meshtastic.keychain
103-
104-
- name: Build
105-
env:
106-
MACOS_SIGNING_IDENTITY: ${{ secrets.MACOS_SIGNING_IDENTITY }}
107-
run: |
108-
pip install pyinstaller
109-
pip install -r requirements.txt
110-
pip install .
111-
pyinstaller -F -n meshtastic --collect-all meshtastic --codesign-identity "$MACOS_SIGNING_IDENTITY" meshtastic/__main__.py
112-
113-
- name: Add mac to release
114-
uses: actions/upload-release-asset@v1
115-
env:
116-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117-
with:
118-
upload_url: ${{ needs.release_create.outputs.upload_url }}
119-
asset_path: dist/meshtastic
120-
asset_name: meshtastic_mac
121-
asset_content_type: application/zip
77+
# build-and-publish-mac:
78+
# runs-on: macos-latest
79+
# needs: release_create
80+
# steps:
81+
# - name: Checkout
82+
# uses: actions/checkout@v3
83+
# with:
84+
# ref: ${{ needs.release_create.outputs.new_sha }}
85+
86+
# - name: Set up Python 3.9
87+
# uses: actions/setup-python@v2
88+
# with:
89+
# python-version: 3.9
90+
91+
# - name: Setup code signing
92+
# env:
93+
# MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
94+
# MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
95+
# MACOS_KEYCHAIN_PASSWORD: ${{ secrets.MACOS_KEYCHAIN_PASSWORD }}
96+
# run: |
97+
# echo $MACOS_CERTIFICATE | base64 --decode > certificate.p12
98+
# security create-keychain -p "$MACOS_KEYCHAIN_PASSWORD" meshtastic.keychain
99+
# security default-keychain -s meshtastic.keychain
100+
# security unlock-keychain -p "$MACOS_KEYCHAIN_PASSWORD" meshtastic.keychain
101+
# security import certificate.p12 -k meshtastic.keychain -P "$MACOS_CERTIFICATE_PWD" -T /usr/bin/codesign
102+
# security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$MACOS_KEYCHAIN_PASSWORD" meshtastic.keychain
103+
104+
# - name: Build
105+
# env:
106+
# MACOS_SIGNING_IDENTITY: ${{ secrets.MACOS_SIGNING_IDENTITY }}
107+
# run: |
108+
# pip install pyinstaller
109+
# pip install -r requirements.txt
110+
# pip install .
111+
# pyinstaller -F -n meshtastic --collect-all meshtastic --codesign-identity "$MACOS_SIGNING_IDENTITY" meshtastic/__main__.py
112+
113+
# - name: Add mac to release
114+
# uses: actions/upload-release-asset@v1
115+
# env:
116+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117+
# with:
118+
# upload_url: ${{ needs.release_create.outputs.upload_url }}
119+
# asset_path: dist/meshtastic
120+
# asset_name: meshtastic_mac
121+
# asset_content_type: application/zip
122122

123123
build-and-publish-ubuntu:
124124
runs-on: ubuntu-latest

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# Add files or directories matching the regex patterns to the blacklist. The
99
# regex matches against base names, not paths.
10-
ignore-patterns=mqtt_pb2.py,channel_pb2.py,telemetry_pb2.py,admin_pb2.py,config_pb2.py,deviceonly_pb2.py,apponly_pb2.py,remote_hardware_pb2.py,portnums_pb2.py,mesh_pb2.py,storeforward_pb2.py,cannedmessages_pb2.py,module_config_pb2.py,localonly_pb2.py,node.py,device_metadata_pb2.py
10+
ignore-patterns=mqtt_pb2.py,channel_pb2.py,telemetry_pb2.py,admin_pb2.py,config_pb2.py,deviceonly_pb2.py,apponly_pb2.py,remote_hardware_pb2.py,portnums_pb2.py,mesh_pb2.py,storeforward_pb2.py,cannedmessages_pb2.py,module_config_pb2.py,localonly_pb2.py,node.py,device_metadata_pb2.py,nanopb_pb2.py
1111

1212

1313

.vscode/launch.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"request": "launch",
1111
"module": "meshtastic",
1212
"justMyCode": false,
13-
"args": ["--debug", "--ble", "--device", "24:62:AB:DD:DF:3A"]
13+
"args": ["--debug", "--ble", "24:62:AB:DD:DF:3A"]
1414
},
1515
{
1616
"name": "meshtastic admin",
@@ -44,6 +44,14 @@
4444
"justMyCode": true,
4545
"args": ["--debug"]
4646
},
47+
{
48+
"name": "meshtastic listen",
49+
"type": "python",
50+
"request": "launch",
51+
"module": "meshtastic",
52+
"justMyCode": true,
53+
"args": ["--listen", "--debug"]
54+
},
4755
{
4856
"name": "meshtastic debug getPref",
4957
"type": "python",

README.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# Meshtastic Python
22

3-
[![codecov](https://codecov.io/gh/meshtastic/Meshtastic-python/branch/master/graph/badge.svg?token=TIWPJL73KV)](https://codecov.io/gh/meshtastic/Meshtastic-python)
3+
[![codecov](https://codecov.io/gh/meshtastic/python/branch/master/graph/badge.svg?token=TIWPJL73KV)](https://codecov.io/gh/meshtastic/python)
44
![PyPI - Downloads](https://img.shields.io/pypi/dm/meshtastic)
55
[![CI](https://img.shields.io/github/actions/workflow/status/meshtastic/python/ci.yml?branch=master&label=actions&logo=github&color=yellow)](https://github.com/meshtastic/python/actions/workflows/ci.yml)
66
[![CLA assistant](https://cla-assistant.io/readme/badge/meshtastic/python)](https://cla-assistant.io/meshtastic/python)
77
[![Fiscal Contributors](https://opencollective.com/meshtastic/tiers/badge.svg?label=Fiscal%20Contributors&color=deeppink)](https://opencollective.com/meshtastic/)
8-
[![Vercel](https://img.shields.io/static/v1?label=Powered%20by&message=Vercel&style=flat&logo=vercel&color=000000)](https://vercel.com?utm_source=meshtastic&utm_campaign=oss)
98

109
## Overview
1110

@@ -16,7 +15,36 @@ Events are delivered using a publish-subscribe model, and you can subscribe to o
1615

1716
**[Getting Started Guide](https://meshtastic.org/docs/software/python/cli/installation)**
1817

19-
**[Documentation/API Reference](https://python.meshtastic.org/)**
18+
(Documentation/API Reference is currently offline)
19+
20+
## Call for Contributors
21+
22+
This library and CLI has gone without a consistent maintainer for a while, and there's many improvements that could be made. We're all volunteers here and help is extremely appreciated, whether in implementing your own needs or helping maintain the library and CLI in general.
23+
24+
If you're interested in contributing but don't have specific things you'd like to work on, look at the roadmap below!
25+
26+
## Roadmap
27+
28+
This should always be considered a list in progress and flux -- inclusion doesn't guarantee implementation, and exclusion doesn't mean something's not wanted. GitHub issues are a great place to discuss ideas.
29+
30+
* Types
31+
* type annotations throughout the codebase
32+
* mypy running in CI to type-check new code
33+
* async-friendliness
34+
* CLI completeness & consistency
35+
* the CLI should support all features of the firmware
36+
* there should be a consistent output format available for shell scripting
37+
* CLI input validation & documentation
38+
* what arguments and options are compatible & incompatible with one another?
39+
* can the options be restructured in a way that is more self-documenting?
40+
* pubsub events should be documented clearly
41+
* helpers for third-party code
42+
* it should be easy to write a script that supports similar options to the CLI so many tools support the same ways of connecting to nodes
43+
* interactive client
44+
* data storage & processing
45+
* there should be a standardized way of recording packets for later use, debugging, etc.
46+
* a sqlite database schema and tools for writing to it may be a good starting point
47+
* enable maps, charts, visualizations
2048

2149
## Stats
2250

TODO.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ Basic functionality is complete now.
55
## Eventual tasks
66

77
- Improve documentation on properties/fields
8-
- change back to Bleak for BLE support - now that they fixed https://github.com/hbldh/bleak/issues/139#event-3499535304
98
- include more examples: textchat.py, replymessage.py all as one little demo
109

1110
- possibly use tk to make a multiwindow test console: https://stackoverflow.com/questions/12351786/how-to-redirect-print-statements-to-tkinter-text-widget
@@ -17,11 +16,8 @@ Basic functionality is complete now.
1716

1817
## Bluetooth support
1918

20-
(Pre-alpha level feature - you probably don't want this one yet)
21-
22-
- This library supports connecting to Meshtastic devices over either USB (serial) or Bluetooth. Before connecting to the device you must [pair](https://docs.ubuntu.com/core/en/stacks/bluetooth/bluez/docs/reference/pairing/outbound.html) your PC with it.
23-
- We use the pip3 install "pygatt[GATTTOOL]"
24-
- ./bin/run.sh --debug --ble --device 24:62:AB:DD:DF:3A
19+
- ./bin/run.sh --ble-scan # To look for Meshtastic devices
20+
- ./bin/run.sh --ble 24:62:AB:DD:DF:3A --info
2521

2622
## Done
2723

bin/regen-protobufs.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
#gsed -i 's/import "\//import ".\//g' ./protobufs/meshtastic/*
55
#gsed -i 's/package meshtastic;//g' ./protobufs/meshtastic/*
66

7-
./nanopb-0.4.7/generator-bin/protoc -I=protobufs --python_out ./ ./protobufs/meshtastic/*.proto
7+
./nanopb-0.4.7/generator-bin/protoc -I=protobufs --python_out ./ --mypy_out ./ ./protobufs/meshtastic/*.proto
8+
./nanopb-0.4.7/generator-bin/protoc -I=protobufs --python_out ./meshtastic/ --mypy_out ./meshtastic/ ./protobufs/nanopb.proto
89

910
# workaround for import bug in protoc https://github.com/protocolbuffers/protobuf/issues/1491#issuecomment-690618628
1011

meshtastic/__init__.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ def onConnection(interface, topic=pub.AUTO_TOPIC): # called when we (re)connect
7171
from typing import *
7272

7373
import google.protobuf.json_format
74-
import serial
75-
import timeago
76-
from dotmap import DotMap
74+
import serial # type: ignore[import-untyped]
75+
import timeago # type: ignore[import-untyped]
76+
from dotmap import DotMap # type: ignore[import-untyped]
7777
from google.protobuf.json_format import MessageToJson
78-
from pubsub import pub
78+
from pubsub import pub # type: ignore[import-untyped]
7979
from tabulate import tabulate
8080

8181
from meshtastic import (
@@ -84,8 +84,11 @@ def onConnection(interface, topic=pub.AUTO_TOPIC): # called when we (re)connect
8484
channel_pb2,
8585
config_pb2,
8686
mesh_pb2,
87+
mqtt_pb2,
88+
paxcount_pb2,
8789
portnums_pb2,
8890
remote_hardware_pb2,
91+
storeforward_pb2,
8992
telemetry_pb2,
9093
util,
9194
)
@@ -127,9 +130,9 @@ class KnownProtocol(NamedTuple):
127130
name: str
128131
# portnum: int, now a key
129132
# If set, will be called to prase as a protocol buffer
130-
protobufFactory: Callable = None
133+
protobufFactory: Optional[Callable] = None
131134
# If set, invoked as onReceive(interface, packet)
132-
onReceive: Callable = None
135+
onReceive: Optional[Callable] = None
133136

134137

135138
def _onTextReceive(iface, asDict):
@@ -190,6 +193,13 @@ def _receiveInfoUpdate(iface, asDict):
190193
portnums_pb2.PortNum.TEXT_MESSAGE_APP: KnownProtocol(
191194
"text", onReceive=_onTextReceive
192195
),
196+
portnums_pb2.PortNum.RANGE_TEST_APP: KnownProtocol(
197+
"rangetest", onReceive=_onTextReceive
198+
),
199+
portnums_pb2.PortNum.DETECTION_SENSOR_APP: KnownProtocol(
200+
"detectionsensor", onReceive=_onTextReceive
201+
),
202+
193203
portnums_pb2.PortNum.POSITION_APP: KnownProtocol(
194204
"position", mesh_pb2.Position, _onPositionReceive
195205
),
@@ -208,4 +218,9 @@ def _receiveInfoUpdate(iface, asDict):
208218
portnums_pb2.PortNum.TRACEROUTE_APP: KnownProtocol(
209219
"traceroute", mesh_pb2.RouteDiscovery
210220
),
221+
portnums_pb2.PortNum.WAYPOINT_APP: KnownProtocol("waypoint", mesh_pb2.Waypoint),
222+
portnums_pb2.PortNum.PAXCOUNTER_APP: KnownProtocol("paxcounter", paxcount_pb2.Paxcount),
223+
portnums_pb2.PortNum.STORE_FORWARD_APP: KnownProtocol("storeforward", storeforward_pb2.StoreAndForward),
224+
portnums_pb2.PortNum.NEIGHBORINFO_APP: KnownProtocol("neighborinfo", mesh_pb2.NeighborInfo),
225+
portnums_pb2.PortNum.MAP_REPORT_APP: KnownProtocol("mapreport", mqtt_pb2.MapReport),
211226
}

0 commit comments

Comments
 (0)