Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions meshtastic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ def onConnection(interface, topic=pub.AUTO_TOPIC): # called when we (re)connect
from typing import *

import google.protobuf.json_format
import serial
import timeago
from dotmap import DotMap
import serial # type: ignore[import-untyped]
import timeago # type: ignore[import-untyped]
from dotmap import DotMap # type: ignore[import-untyped]
from google.protobuf.json_format import MessageToJson
from pubsub import pub
from pubsub import pub # type: ignore[import-untyped]
from tabulate import tabulate

from meshtastic import (
Expand Down Expand Up @@ -127,9 +127,9 @@ class KnownProtocol(NamedTuple):
name: str
# portnum: int, now a key
# If set, will be called to prase as a protocol buffer
protobufFactory: Callable = None
protobufFactory: Optional[Callable] = None
# If set, invoked as onReceive(interface, packet)
onReceive: Callable = None
onReceive: Optional[Callable] = None


def _onTextReceive(iface, asDict):
Expand Down
9 changes: 7 additions & 2 deletions meshtastic/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ def setPref(config, comp_name, valStr) -> bool:
val = meshtastic.util.fromStr(valStr)
logging.debug(f"valStr:{valStr} val:{val}")

if snake_name == "psk" and len(valStr) < 8:
print(f"Warning: wifi.psk must be 8 or more characters.")
if snake_name == "wifi_psk" and len(valStr) < 8:
print(f"Warning: network.wifi_psk must be 8 or more characters.")
Comment on lines +163 to +164
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit hadn't been updated for the new config format, so that's a bug fixed at least.

return False

enumType = pref.enum_type
Expand Down Expand Up @@ -638,6 +638,11 @@ def onConnected(interface):

def setSimpleConfig(modem_preset):
"""Set one of the simple modem_config"""
channelIndex = our_globals.get_channel_index()
if channelIndex is not None and channelIndex > 0:
meshtastic.util.our_exit(
"Warning: Cannot set modem preset for non-primary channel", 1
)
Comment on lines +641 to +645
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had a test expecting to enforce this, but weren't doing so. So if channel index is passed along with a modem preset, we expect it to be 0 now.

# Overwrite modem_preset
prefs = interface.getNode(args.dest).localConfig
prefs.lora.modem_preset = modem_preset
Expand Down
1 change: 0 additions & 1 deletion meshtastic/mesh_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ def showInfo(self, file=sys.stdout): # pylint: disable=W0613

# use id as dictionary key for correct json format in list of nodes
nodeid = n2["user"]["id"]
n2["user"].pop("id")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why we did this other than to clean up the display, but it meant if this got called and later something else needed the ID, it would fail.

nodes[nodeid] = n2
infos = owner + myinfo + metadata + mesh + json.dumps(nodes)
print(infos)
Expand Down
Loading