mirror of
https://github.com/meshtastic/python.git
synced 2026-01-03 21:37:57 -05:00
1.0.3
This commit is contained in:
@@ -55,7 +55,7 @@ from pubsub import pub
|
||||
def onReceive(packet, interface): # called when a packet arrives
|
||||
print(f"Received: {packet}")
|
||||
|
||||
def onConnection(interface, topic): # called when we (re)connect to the radio
|
||||
def onConnection(interface, topic=pub.AUTO_TOPIC): # called when we (re)connect to the radio
|
||||
# defaults to broadcast, specify a destination ID if you wish
|
||||
interface.sendText("hello mesh")
|
||||
|
||||
@@ -105,7 +105,7 @@ from pubsub import pub
|
||||
def onReceive(packet, interface): # called when a packet arrives
|
||||
print(f"Received: {packet}")
|
||||
|
||||
def onConnection(interface, topic): # called when we (re)connect to the radio
|
||||
def onConnection(interface, topic=pub.AUTO_TOPIC): # called when we (re)connect to the radio
|
||||
# defaults to broadcast, specify a destination ID if you wish
|
||||
interface.sendText("hello mesh")
|
||||
|
||||
@@ -174,6 +174,7 @@ class MeshInterface:
|
||||
|
||||
Keyword Arguments:
|
||||
destinationId {nodeId or nodeNum} -- where to send this message (default: {BROADCAST_ADDR})
|
||||
wantAck -- True if you want the message sent in a reliable manner (with retries and ack/nak provided for delivery)
|
||||
|
||||
Returns the sent packet. The id field will be populated in this packet and can be used to track future message acks/naks.
|
||||
"""
|
||||
@@ -183,6 +184,10 @@ class MeshInterface:
|
||||
def sendData(self, byteData, destinationId=BROADCAST_ADDR, dataType=mesh_pb2.Data.OPAQUE, wantAck=False, wantResponse=False):
|
||||
"""Send a data packet to some other node
|
||||
|
||||
Keyword Arguments:
|
||||
destinationId {nodeId or nodeNum} -- where to send this message (default: {BROADCAST_ADDR})
|
||||
wantAck -- True if you want the message sent in a reliable manner (with retries and ack/nak provided for delivery)
|
||||
|
||||
Returns the sent packet. The id field will be populated in this packet and can be used to track future message acks/naks.
|
||||
"""
|
||||
meshPacket = mesh_pb2.MeshPacket()
|
||||
@@ -258,8 +263,11 @@ class MeshInterface:
|
||||
|
||||
def _generatePacketId(self):
|
||||
"""Get a new unique packet ID"""
|
||||
self.currentPacketId = (self.currentPacketId + 1) & 0xffffffff
|
||||
return self.currentPacketId
|
||||
if self.currentPacketId is None:
|
||||
raise Exception("Not connected yet, can not generate packet")
|
||||
else:
|
||||
self.currentPacketId = (self.currentPacketId + 1) & 0xffffffff
|
||||
return self.currentPacketId
|
||||
|
||||
def _disconnected(self):
|
||||
"""Called by subclasses to tell clients this interface has disconnected"""
|
||||
@@ -353,7 +361,7 @@ class MeshInterface:
|
||||
try:
|
||||
return self._nodesByNum[num]["user"]["id"]
|
||||
except:
|
||||
logging.error("Node not found for fromId")
|
||||
logging.warn("Node not found for fromId")
|
||||
return None
|
||||
|
||||
def _getOrCreateByNum(self, nodeNum):
|
||||
@@ -745,6 +753,7 @@ debugOut</p>
|
||||
|
||||
Keyword Arguments:
|
||||
destinationId {nodeId or nodeNum} -- where to send this message (default: {BROADCAST_ADDR})
|
||||
wantAck -- True if you want the message sent in a reliable manner (with retries and ack/nak provided for delivery)
|
||||
|
||||
Returns the sent packet. The id field will be populated in this packet and can be used to track future message acks/naks.
|
||||
"""
|
||||
@@ -754,6 +763,10 @@ debugOut</p>
|
||||
def sendData(self, byteData, destinationId=BROADCAST_ADDR, dataType=mesh_pb2.Data.OPAQUE, wantAck=False, wantResponse=False):
|
||||
"""Send a data packet to some other node
|
||||
|
||||
Keyword Arguments:
|
||||
destinationId {nodeId or nodeNum} -- where to send this message (default: {BROADCAST_ADDR})
|
||||
wantAck -- True if you want the message sent in a reliable manner (with retries and ack/nak provided for delivery)
|
||||
|
||||
Returns the sent packet. The id field will be populated in this packet and can be used to track future message acks/naks.
|
||||
"""
|
||||
meshPacket = mesh_pb2.MeshPacket()
|
||||
@@ -829,8 +842,11 @@ debugOut</p>
|
||||
|
||||
def _generatePacketId(self):
|
||||
"""Get a new unique packet ID"""
|
||||
self.currentPacketId = (self.currentPacketId + 1) & 0xffffffff
|
||||
return self.currentPacketId
|
||||
if self.currentPacketId is None:
|
||||
raise Exception("Not connected yet, can not generate packet")
|
||||
else:
|
||||
self.currentPacketId = (self.currentPacketId + 1) & 0xffffffff
|
||||
return self.currentPacketId
|
||||
|
||||
def _disconnected(self):
|
||||
"""Called by subclasses to tell clients this interface has disconnected"""
|
||||
@@ -924,7 +940,7 @@ debugOut</p>
|
||||
try:
|
||||
return self._nodesByNum[num]["user"]["id"]
|
||||
except:
|
||||
logging.error("Node not found for fromId")
|
||||
logging.warn("Node not found for fromId")
|
||||
return None
|
||||
|
||||
def _getOrCreateByNum(self, nodeNum):
|
||||
@@ -999,6 +1015,9 @@ debugOut</p>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Send a data packet to some other node</p>
|
||||
<p>Keyword Arguments:
|
||||
destinationId {nodeId or nodeNum} – where to send this message (default: {BROADCAST_ADDR})
|
||||
wantAck – True if you want the message sent in a reliable manner (with retries and ack/nak provided for delivery)</p>
|
||||
<p>Returns the sent packet. The id field will be populated in this packet and can be used to track future message acks/naks.</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
@@ -1007,6 +1026,10 @@ debugOut</p>
|
||||
<pre><code class="python">def sendData(self, byteData, destinationId=BROADCAST_ADDR, dataType=mesh_pb2.Data.OPAQUE, wantAck=False, wantResponse=False):
|
||||
"""Send a data packet to some other node
|
||||
|
||||
Keyword Arguments:
|
||||
destinationId {nodeId or nodeNum} -- where to send this message (default: {BROADCAST_ADDR})
|
||||
wantAck -- True if you want the message sent in a reliable manner (with retries and ack/nak provided for delivery)
|
||||
|
||||
Returns the sent packet. The id field will be populated in this packet and can be used to track future message acks/naks.
|
||||
"""
|
||||
meshPacket = mesh_pb2.MeshPacket()
|
||||
@@ -1106,7 +1129,8 @@ the local position.</p>
|
||||
<h2 id="arguments">Arguments</h2>
|
||||
<p>text {string} – The text to send</p>
|
||||
<p>Keyword Arguments:
|
||||
destinationId {nodeId or nodeNum} – where to send this message (default: {BROADCAST_ADDR})</p>
|
||||
destinationId {nodeId or nodeNum} – where to send this message (default: {BROADCAST_ADDR})
|
||||
wantAck – True if you want the message sent in a reliable manner (with retries and ack/nak provided for delivery)</p>
|
||||
<p>Returns the sent packet. The id field will be populated in this packet and can be used to track future message acks/naks.</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
@@ -1120,6 +1144,7 @@ destinationId {nodeId or nodeNum} – where to send this message (default: {
|
||||
|
||||
Keyword Arguments:
|
||||
destinationId {nodeId or nodeNum} -- where to send this message (default: {BROADCAST_ADDR})
|
||||
wantAck -- True if you want the message sent in a reliable manner (with retries and ack/nak provided for delivery)
|
||||
|
||||
Returns the sent packet. The id field will be populated in this packet and can be used to track future message acks/naks.
|
||||
"""
|
||||
|
||||
2
setup.py
2
setup.py
@@ -10,7 +10,7 @@ with open("README.md", "r") as fh:
|
||||
# This call to setup() does all the work
|
||||
setup(
|
||||
name="meshtastic",
|
||||
version="1.0.2",
|
||||
version="1.0.3",
|
||||
description="Python API & client shell for talking to Meshtastic devices",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
|
||||
Reference in New Issue
Block a user