From 6d3c34878beea85d85e14ffe06ce709bea780048 Mon Sep 17 00:00:00 2001 From: geeksville Date: Tue, 12 May 2020 18:16:35 -0700 Subject: [PATCH] fix db updates --- .vscode/launch.json | 8 ++++++++ TODO.md | 13 +++++++------ meshtastic/__init__.py | 16 ++++++++++++---- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 16b4c5d..5fe68ed 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -19,6 +19,14 @@ "module": "meshtastic", "justMyCode": true, "args": ["--debug", "--info"] + }, + { + "name": "meshtastic shell", + "type": "python", + "request": "launch", + "module": "meshtastic", + "justMyCode": true, + "args": ["--debug", "--seriallog", "stdout"] } ] } diff --git a/TODO.md b/TODO.md index 58c9579..ca6f66d 100644 --- a/TODO.md +++ b/TODO.md @@ -3,15 +3,13 @@ ## Bluetooth support (Alpha level feature) -This library supports connecting to Meshtastic devices over either USB (serial) or Bluetooth. Before connecting to the device you must [pair](https://docs.ubuntu.com/core/en/stacks/bluetooth/bluez/docs/reference/pairing/outbound.html) your PC with it. -We use the pip3 install "pygatt[GATTTOOL]" + +- This library supports connecting to Meshtastic devices over either USB (serial) or Bluetooth. Before connecting to the device you must [pair](https://docs.ubuntu.com/core/en/stacks/bluetooth/bluez/docs/reference/pairing/outbound.html) your PC with it. +- We use the pip3 install "pygatt[GATTTOOL]" +- ./bin/run.sh --debug --ble --device 24:62:AB:DD:DF:3A ## Before beta -- ./bin/run.sh --debug --ble --device 24:62:AB:DD:DF:3A -- update nodedb as nodes change -- radioConfig - getter/setter syntax: https://www.python-course.eu/python3_properties.php -- let user change radio params via commandline options - document properties/fields - include more examples: textchat.py, replymessage.py all as one little demo - have device side StreamAPI client prevent radio sleep @@ -42,3 +40,6 @@ We use the pip3 install "pygatt[GATTTOOL]" - DONE have device send a special packet at boot so the serial client can detect if it rebooted - DONE add fromId and toId to received messages dictionaries - make command line options for displaying/changing config +- update nodedb as nodes change +- radioConfig - getter/setter syntax: https://www.python-course.eu/python3_properties.php +- let user change radio params via commandline options \ No newline at end of file diff --git a/meshtastic/__init__.py b/meshtastic/__init__.py index 4b466f0..ab9e19d 100644 --- a/meshtastic/__init__.py +++ b/meshtastic/__init__.py @@ -211,7 +211,7 @@ class MeshInterface: return BROADCAST_ADDR try: - return self._nodesByNum[num].user.id + return self._nodesByNum[num]["user"]["id"] except: logging.error("Node not found for fromId") return None @@ -235,11 +235,17 @@ class MeshInterface: topic = None if meshPacket.decoded.HasField("position"): topic = "meshtastic.receive.position" - self._fixupPosition(asDict["payload"]["position"]) - # FIXME, update node DB as needed + p = asDict["decoded"]["position"] + self._fixupPosition(p) + # update node DB as needed + self._nodesByNum[asDict["from"]]["position"] = p + if meshPacket.decoded.HasField("user"): topic = "meshtastic.receive.user" - # FIXME, update node DB as needed + u = asDict["decoded"]["user"] + # update node DB as needed + self._nodesByNum[asDict["from"]]["user"] = u + if meshPacket.decoded.HasField("data"): topic = "meshtastic.receive.data" # For text messages, we go ahead and decode the text to ascii for our users @@ -257,6 +263,8 @@ FROMNUM_UUID = "ed9da18c-a800-4f66-a670-aa7547e34453" class BLEInterface(MeshInterface): + """A not quite ready - FIXME - BLE interface to devices""" + def __init__(self, address, debugOut=None): self.address = address self.adapter = pygatt.GATTToolBackend() # BGAPIBackend()