Skip to content

Commit

Permalink
Merge pull request #607 from geeksville/pr-powermon
Browse files Browse the repository at this point in the history
PowerMon/StructuredLogging support
  • Loading branch information
ianmcorvidae authored Jul 8, 2024
2 parents 62cfe2d + 6332798 commit c049433
Show file tree
Hide file tree
Showing 34 changed files with 3,708 additions and 180 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
Expand Down Expand Up @@ -56,7 +55,6 @@ jobs:
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ __pycache__
examples/__pycache__
meshtastic.spec
.hypothesis/
coverage.xml
coverage.xml
.ipynb_checkpoints
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ignore-patterns=mqtt_pb2.py,channel_pb2.py,telemetry_pb2.py,admin_pb2.py,config_
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
#
disable=invalid-name,fixme,logging-fstring-interpolation,too-many-statements,too-many-branches,too-many-locals,no-member,f-string-without-interpolation,protected-access,pointless-string-statement,too-few-public-methods,broad-except,no-else-return,no-else-raise,bare-except,too-many-public-methods
disable=invalid-name,fixme,logging-fstring-interpolation,too-many-statements,too-many-branches,too-many-locals,no-member,f-string-without-interpolation,protected-access,pointless-string-statement,too-few-public-methods,broad-except,no-else-return,no-else-raise,bare-except,too-many-public-methods,nested-min-max

[BASIC]

Expand Down
80 changes: 52 additions & 28 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"configurations": [
{
"name": "meshtastic BLE",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": false,
"args": ["--ble", "Meshtastic_9f6e"]
"args": ["--ble", "--info", "--seriallog", "stdout"]
},
{
"name": "meshtastic BLE scan",
Expand All @@ -22,63 +22,63 @@
},
{
"name": "meshtastic admin",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--setch-longslow", "--port", "/dev/ttyUSB1"]
},
{
"name": "meshtastic tunnel",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--tunnel", "--debug"]
},
{
"name": "meshtastic set chan",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--setchan", "psk", "0x1a1a1a1a2b2b2b2b1a1a1a1a2b2b2b2b1a1a1a1a2b2b2b2b1a1a1a1a2b2b2b2b", "--debug"]
},
{
"name": "meshtastic debug",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug"]
},
{
"name": "meshtastic listen",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--listen", "--debug"]
},
{
"name": "meshtastic debug getPref",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--get", "power.is_power_saving"]
},
{
"name": "meshtastic debug getPref telemetry",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--get", "telemetry.environment_update_interval"]
},
{
"name": "meshtastic debug info",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
Expand All @@ -94,71 +94,71 @@
},
{
"name": "meshtastic debug set region",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--set", "lora.region", "TW"]
},
{
"name": "meshtastic debug set bluetooth fixed pin",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--set", "bluetooth.fixed_pin", "555555"]
},
{
"name": "meshtastic debug get bluetooth fixed pin",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--get", "bluetooth.fixed_pin"]
},
{
"name": "meshtastic debug setPref",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--set", "power.is_power_saving", "1"]
"args": ["--set", "power.powermon_enables", "65527"]
},
{
"name": "meshtastic debug setPref telemetry.environment_measurement_enabled",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--set", "telemetry.environment_measurement_enabled", "1"]
},
{
"name": "meshtastic debug setPref telemetry.environment_screen_enabled",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--set", "telemetry.environment_screen_enabled", "1"]
},
{
"name": "meshtastic debug setPref telemetry",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--set", "telemetry.environment_measurement_enabled", "1"]
},
{
"name": "meshtastic setpref",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--setchan", "psk", ""]
},
{
"name": "meshtastic --ch-set",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
Expand All @@ -167,7 +167,7 @@

{
"name": "meshtastic seturl",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
Expand All @@ -176,39 +176,63 @@
},
{
"name": "meshtastic shell",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--seriallog"]
"justMyCode": false,
"args": ["--noproto", "--seriallog", "stdout"]
},
{
"name": "meshtastic powermon sim",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": false,
"args": ["--slog-out", "default", "--power-sim", "--power-voltage", "3.3", "--port", "/dev/ttyUSB0", "--noproto", "--seriallog", "stdout"]
},
{
"name": "meshtastic powermon ppk2",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": false,
"args": ["--slog-out", "default", "--power-ppk2-meter", "--power-wait", "--power-voltage", "3.3", "--noproto", "--seriallog", "stdout"]
},
{
"name": "meshtastic stress ppk2",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": false,
"args": ["--slog-out", "default", "--power-ppk2-meter", "--power-stress", "--power-voltage", "3.3", "--seriallog"]
},
{
"name": "meshtastic test",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--test"]
},
{
"name": "meshtastic settime",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--settime"]
},
{
"name": "meshtastic sendtext",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--sendtext", "pytest"]
},
{
"name": "meshtastic showNodes",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
Expand Down
10 changes: 9 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
{
"cSpell.words": [
"bitmask",
"boardid",
"Meshtastic",
"milliwatt",
"portnums",
"powermon",
"POWERSTRESS",
"pyarrow",
"TORADIO",
"Vids"
],
"python.pythonPath": "/usr/bin/python3"
"python.pythonPath": "/usr/bin/python3",
"flake8.enabled" : false // we are using trunk for formatting/linting rules, don't yell at us about line length
}
6 changes: 6 additions & 0 deletions bin/prerelease-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ set -e

# You may consider running: "pytest -m smoke1" instead of this test.

echo "Linting"
poetry run pylint meshtastic examples/ --ignore-patterns ".*_pb2.pyi?$"

echo "Checking types"
poetry run mypy meshtastic/

echo "Running (crude) prerelease tests to verify sanity"

# Use the python environment created by poetry
Expand Down
5 changes: 5 additions & 0 deletions meshtastic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
- 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...)
- meshtastic.log.line(line) - a raw unparsed log line from the radio
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
Expand Down Expand Up @@ -96,6 +97,7 @@ def onConnection(interface, topic=pub.AUTO_TOPIC): # called when we (re)connect
remote_hardware_pb2,
storeforward_pb2,
telemetry_pb2,
powermon_pb2
)
from . import (
util,
Expand Down Expand Up @@ -228,6 +230,9 @@ def _receiveInfoUpdate(iface, asDict):
portnums_pb2.PortNum.TRACEROUTE_APP: KnownProtocol(
"traceroute", mesh_pb2.RouteDiscovery
),
portnums_pb2.PortNum.POWERSTRESS_APP: KnownProtocol(
"powerstress", powermon_pb2.PowerStressMessage
),
portnums_pb2.PortNum.WAYPOINT_APP: KnownProtocol("waypoint", mesh_pb2.Waypoint),
portnums_pb2.PortNum.PAXCOUNTER_APP: KnownProtocol("paxcounter", paxcount_pb2.Paxcount),
portnums_pb2.PortNum.STORE_FORWARD_APP: KnownProtocol("storeforward", storeforward_pb2.StoreAndForward),
Expand Down
Loading

0 comments on commit c049433

Please sign in to comment.