Compare commits

...

19 Commits
2.4.0 ... 2.4.1

Author SHA1 Message Date
github-actions
23bb2e26f9 bump version to 2.4.1 2024-09-05 21:22:03 +00:00
Ian McEwen
b59ecff272 Merge pull request #666 from ianmcorvidae/fix-set-owner
Ensure set-owner combined with set-owner-short sets both values
2024-09-05 13:58:36 -07:00
Ian McEwen
17f3605736 Ensure set-owner combined with set-owner-short sets both values 2024-09-05 13:58:02 -07:00
Ian McEwen
a689fd73a2 Deprecate --no-time and remove behavior, followup to #663 2024-09-05 13:49:28 -07:00
Ian McEwen
da30e1141a Merge pull request #663 from meshtastic/outtatime
Don't automatically set the time from Python
2024-09-05 13:47:36 -07:00
Ian McEwen
b4bd9568e4 Merge pull request #664 from lysol/master
Reuse node to prevent overwriting channel settings
2024-09-03 16:12:13 -07:00
Derek Arnold
aed4f25cf5 Reuse node to prevent overwriting channel settings to be sent out over the admin channel 2024-09-03 17:41:05 -05:00
Jonathan Bennett
5c312bedc1 Remove assert from test, due to removed position time 2024-08-30 01:15:40 -05:00
Jonathan Bennett
428e9a228c Remove unused time variable 2024-08-29 23:09:04 -05:00
Jonathan Bennett
4500850063 Don't automatically set the time from Python
The Python MO is to do as little as possible beyond what the user has intentionally instructed. So don't try to set the time automatically.
2024-08-29 22:29:20 -05:00
Ian McEwen
bcce5687c5 Merge pull request #659 from wnagele/unreachable_code
Code block unreachable
2024-08-25 13:18:06 -07:00
Ian McEwen
b9d805057f Merge pull request #658 from wnagele/master
Add method to be able to send heartbeat
2024-08-25 13:17:51 -07:00
Wolfgang Nagele
d77335caa7 Add sendHeartbeat doc-string 2024-08-25 22:13:08 +02:00
Wolfgang Nagele
b692ef4cfb Add method to be able to send heartbeat 2024-08-25 14:47:41 +02:00
Wolfgang Nagele
e725292ee0 Code block unreachable 2024-08-25 14:39:37 +02:00
Ian McEwen
abf9e96d3d Set release tag to the version update commit sha, not the pre-update one 2024-08-21 20:07:12 -07:00
Ian McEwen
740f0f0961 set prerelease version to match protobufs 2024-08-21 19:53:23 -07:00
Ian McEwen
abb00251c0 protobufs: v2.4.1 2024-08-21 19:52:56 -07:00
github-actions
3335b3d651 bump version to 2.4.0 2024-08-22 02:23:53 +00:00
9 changed files with 55 additions and 67 deletions

View File

@@ -52,6 +52,7 @@ jobs:
prerelease: true
release_name: Meshtastic Python ${{ steps.get_version.outputs.version }}
tag_name: ${{ steps.get_version.outputs.version }}
commitish: ${{ steps.commit_updated.outputs.sha }}
body: |
Autogenerated by github action, developer should edit as required before publishing...
env:

View File

@@ -314,35 +314,17 @@ def onConnected(interface):
print("Setting device position and enabling fixed position setting")
# can include lat/long/alt etc: latitude = 37.5, longitude = -122.1
interface.localNode.setFixedPosition(lat, lon, alt)
elif not args.no_time:
# We normally provide a current time to the mesh when we connect
if (
interface.localNode.nodeNum in interface.nodesByNum
and "position" in interface.nodesByNum[interface.localNode.nodeNum]
):
# send the same position the node already knows, just to update time
position = interface.nodesByNum[interface.localNode.nodeNum]["position"]
interface.sendPosition(
position.get("latitude", 0.0),
position.get("longitude", 0.0),
position.get("altitude", 0.0),
)
else:
interface.sendPosition()
if args.set_owner:
if args.set_owner or args.set_owner_short:
closeNow = True
waitForAckNak = True
print(f"Setting device owner to {args.set_owner}")
interface.getNode(args.dest, False).setOwner(args.set_owner)
if args.set_owner_short:
closeNow = True
waitForAckNak = True
print(f"Setting device owner short to {args.set_owner_short}")
interface.getNode(args.dest, False).setOwner(
long_name=None, short_name=args.set_owner_short
)
if args.set_owner and args.set_owner_short:
print(f"Setting device owner to {args.set_owner} and short name to {args.set_owner_short}")
elif args.set_owner:
print(f"Setting device owner to {args.set_owner}")
else: # short name only
print(f"Setting device owner short to {args.set_owner_short}")
interface.getNode(args.dest, False).setOwner(long_name=args.set_owner, short_name=args.set_owner_short)
# TODO: add to export-config and configure
if args.set_canned_message:
@@ -778,7 +760,8 @@ def onConnected(interface):
channelIndex = mt_config.channel_index
if channelIndex is None:
meshtastic.util.our_exit("Warning: Need to specify '--ch-index'.", 1)
ch = interface.getNode(args.dest).channels[channelIndex]
node = interface.getNode(args.dest)
ch = node.channels[channelIndex]
if args.ch_enable or args.ch_disable:
print(
@@ -836,7 +819,7 @@ def onConnected(interface):
ch.role = channel_pb2.Channel.Role.DISABLED
print(f"Writing modified channels to device")
interface.getNode(args.dest).writeChannel(channelIndex)
node.writeChannel(channelIndex)
if args.get_canned_message:
closeNow = True
@@ -1466,6 +1449,10 @@ def initParser():
group.add_argument("--set-owner", help="Set device owner name", action="store")
group.add_argument(
"--set-owner-short", help="Set device owner short name", action="store"
)
group.add_argument(
"--set-canned-message",
help="Set the canned messages plugin message (up to 200 characters).",
@@ -1478,10 +1465,6 @@ def initParser():
action="store",
)
group.add_argument(
"--set-owner-short", help="Set device owner short name", action="store"
)
group.add_argument(
"--set-ham", help="Set licensed Ham ID and turn off encryption", action="store"
)
@@ -1587,7 +1570,7 @@ def initParser():
group.add_argument(
"--no-time",
help="Suppress sending the current time to the mesh",
help="Deprecated. Retained for backwards compatibility in scripts, but is a no-op.",
action="store_true",
)

View File

@@ -442,7 +442,6 @@ class MeshInterface: # pylint: disable=R0902
latitude: float = 0.0,
longitude: float = 0.0,
altitude: int = 0,
timeSec: int = 0,
destinationId: Union[int, str] = BROADCAST_ADDR,
wantAck: bool = False,
wantResponse: bool = False,
@@ -454,8 +453,6 @@ class MeshInterface: # pylint: disable=R0902
Also, the device software will notice this packet and use it to automatically
set its notion of the local position.
If timeSec is not specified (recommended), we will use the local machine time.
Returns the sent packet. The id field will be populated in this packet and
can be used to track future message acks/naks.
"""
@@ -472,11 +469,6 @@ class MeshInterface: # pylint: disable=R0902
p.altitude = int(altitude)
logging.debug(f"p.altitude:{p.altitude}")
if timeSec == 0:
timeSec = int(time.time()) # returns unix timestamp in seconds
p.time = timeSec
logging.debug(f"p.time:{p.time}")
if wantResponse:
onResponse = self.onResponsePosition
else:
@@ -812,19 +804,22 @@ class MeshInterface: # pylint: disable=R0902
lambda: pub.sendMessage("meshtastic.connection.lost", interface=self)
)
def sendHeartbeat(self):
"""Sends a heartbeat to the radio. Can be used to verify the connection is healthy."""
p = mesh_pb2.ToRadio()
p.heartbeat.CopyFrom(mesh_pb2.Heartbeat())
self._sendToRadio(p)
def _startHeartbeat(self):
"""We need to send a heartbeat message to the device every X seconds"""
def callback():
self.heartbeatTimer = None
i = 300
logging.debug(f"Sending heartbeat, interval {i} seconds")
if i != 0:
self.heartbeatTimer = threading.Timer(i, callback)
self.heartbeatTimer.start()
p = mesh_pb2.ToRadio()
p.heartbeat.CopyFrom(mesh_pb2.Heartbeat())
self._sendToRadio(p)
interval = 300
logging.debug(f"Sending heartbeat, interval {interval} seconds")
self.heartbeatTimer = threading.Timer(interval, callback)
self.heartbeatTimer.start()
self.sendHeartbeat()
callback() # run our periodic callback now, it will make another timer if necessary
@@ -975,13 +970,6 @@ class MeshInterface: # pylint: disable=R0902
self.localNode.nodeNum = self.myInfo.my_node_num
logging.debug(f"Received myinfo: {stripnl(fromRadio.my_info)}")
failmsg = None
if failmsg:
self.failure = MeshInterface.MeshInterfaceError(failmsg)
self.isConnected.set() # let waitConnected return this exception
self.close()
elif fromRadio.HasField("metadata"):
self.metadata = fromRadio.metadata
logging.debug(f"Received device metadata: {stripnl(fromRadio.metadata)}")

View File

@@ -5,7 +5,7 @@ import base64
import logging
import time
from typing import Union
from typing import Optional, Union
from meshtastic.protobuf import admin_pb2, apponly_pb2, channel_pb2, localonly_pb2, mesh_pb2, portnums_pb2
from meshtastic.util import (
@@ -279,7 +279,7 @@ class Node:
return c.index
return 0
def setOwner(self, long_name=None, short_name=None, is_licensed=False):
def setOwner(self, long_name: Optional[str]=None, short_name: Optional[str]=None, is_licensed: bool=False):
"""Set device owner name"""
logging.debug(f"in setOwner nodeNum:{self.nodeNum}")
p = admin_pb2.AdminMessage()

View File

File diff suppressed because one or more lines are too long

View File

@@ -324,6 +324,14 @@ class _HardwareModelEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._
Heltec Mesh Node T114 board with nRF52840 CPU, and a 1.14 inch TFT display, Ultimate low-power design,
specifically adapted for the Meshtatic project
"""
SENSECAP_INDICATOR: _HardwareModel.ValueType # 70
"""
Sensecap Indicator from Seeed Studio. ESP32-S3 device with TFT and RP2040 coprocessor
"""
TRACKER_T1000_E: _HardwareModel.ValueType # 71
"""
Seeed studio T1000-E tracker card. NRF52840 w/ LR1110 radio, GPS, button, buzzer, and sensors.
"""
PRIVATE_HW: _HardwareModel.ValueType # 255
"""
------------------------------------------------------------------------------------------------------------------------------------------
@@ -632,6 +640,14 @@ HELTEC_MESH_NODE_T114: HardwareModel.ValueType # 69
Heltec Mesh Node T114 board with nRF52840 CPU, and a 1.14 inch TFT display, Ultimate low-power design,
specifically adapted for the Meshtatic project
"""
SENSECAP_INDICATOR: HardwareModel.ValueType # 70
"""
Sensecap Indicator from Seeed Studio. ESP32-S3 device with TFT and RP2040 coprocessor
"""
TRACKER_T1000_E: HardwareModel.ValueType # 71
"""
Seeed studio T1000-E tracker card. NRF52840 w/ LR1110 radio, GPS, button, buzzer, and sensors.
"""
PRIVATE_HW: HardwareModel.ValueType # 255
"""
------------------------------------------------------------------------------------------------------------------------------------------

View File

@@ -185,7 +185,7 @@ def test_sendPosition(caplog):
with caplog.at_level(logging.DEBUG):
iface.sendPosition()
iface.close()
assert re.search(r"p.time:", caplog.text, re.MULTILINE)
# assert re.search(r"p.time:", caplog.text, re.MULTILINE)
# TODO

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "meshtastic"
version = "2.4.0a0"
version = "2.4.1"
description = "Python API & client shell for talking to Meshtastic devices"
authors = ["Meshtastic Developers <contact@meshtastic.org>"]
license = "GPL-3.0-only"