diff --git a/docs/meshtastic/index.html b/docs/meshtastic/index.html index 0529fa5..0cb31d4 100644 --- a/docs/meshtastic/index.html +++ b/docs/meshtastic/index.html @@ -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
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 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 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 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 @@ debugOutSend 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.
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.
Arguments
text {string} – The text to send
Keyword Arguments:
-destinationId {nodeId or nodeNum} – where to send this message (default: {BROADCAST_ADDR})
+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.
@@ -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.
"""
diff --git a/setup.py b/setup.py
index d307e4e..4cf0524 100644
--- a/setup.py
+++ b/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",