Skip to main content

A python package for managing a Meshtastic node database.

Project description

meshdb

A lightweight Python library for storing Meshtastic node, telemetry, and message data in per-node SQLite databases.

Installation

You can install meshdb directly from PyPI using pip:

pip install meshdb

Or install from source within a virtual environment:

git clone https://github.com/pdxlocations/meshdb.git
cd meshdb
pip install -e .

Or install via Poetry:

poetry install

Quick Usage Example

Set a default database path and handle incoming packets:

from meshdb import handle_packet, set_default_db_path

set_default_db_path("./data")

packet = {
    "from": 12345678,
    "rxTime": 1700000000,
    "decoded": {
        "portnum": "NODEINFO_APP",
        "user": {"longName": "TestNode"}
    }
}

handle_packet(packet, node_database_number=12345678)

Network Connection Options (Serial/TCP/Virtual Node)

meshdb now includes a connection helper that supports:

  • serial (default)
  • tcp
  • udp virtual-node mode
import meshdb

conn = meshdb.connect(
    transport="udp",
    virtual_node=meshdb.VirtualNodeConfig(
        node_id="!89abcdef",
        long_name="MeshDB Virtual Node",
        short_name="MDB",
        channel="LongFast",
        key="AQ==",
        mcast_group="224.0.0.69",
        mcast_port=4403,
    ),
)
print(conn.transport, conn.owner_node_num)

When receiving packets from udp, use meshdb.normalize_packet(packet, "udp") before passing to meshdb.handle_packet(...).

CLI Listener

You can run:

meshdb
meshdb --db ./data --transport tcp --tcp-host 127.0.0.1:4403
meshdb --transport udp --node-id !89abcdef --channel LongFast

This connects to the mesh, listens for new packets, and persists them into the owner database until you stop it with Ctrl+C.

The CLI is configured with explicit arguments rather than environment variables. For udp transport, you can also pass:

  • --long-name
  • --short-name
  • --hw-model
  • --key
  • --mcast-group
  • --mcast-port

Owner Database

meshdb stores data per owner node. The owner_node_num value selects which owner's SQLite database and table set you are reading or writing.

That matters because the same remote node can appear differently depending on which local node observed it. Signal, last-heard time, hops, and even the available node list are owner-specific.

If you have a live Meshtastic interface and want to import its current NodeDB snapshot, you can do:

import meshdb

count = meshdb.sync_nodes_from_interface(owner_node_num, interface)
print(f"imported {count} nodes")

Lookups in Code

import meshdb

meshdb.set_default_db_path("./data")

node = meshdb.get_node(12345678, owner_node_num=12345678)
battery = meshdb.get_node_metric("TestNode", "battery_level", owner_node_num=12345678)

Project Status

Early development. Schema and API changes may occur.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

meshdb-0.1.10.tar.gz (33.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

meshdb-0.1.10-py3-none-any.whl (35.1 kB view details)

Uploaded Python 3

File details

Details for the file meshdb-0.1.10.tar.gz.

File metadata

  • Download URL: meshdb-0.1.10.tar.gz
  • Upload date:
  • Size: 33.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for meshdb-0.1.10.tar.gz
Algorithm Hash digest
SHA256 4245db26ae77c4c0070c1a3bb85d9f51ed70a17518698662ff9d13b706f5ac38
MD5 6f2c8b33ce3afdf4f7451a028f7eebca
BLAKE2b-256 92cc1629bd370e89a1a37e98a7edbf4e01736eecd732f2dfc154e5ddd071743e

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshdb-0.1.10.tar.gz:

Publisher: release.yaml on pdxlocations/meshdb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file meshdb-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: meshdb-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 35.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for meshdb-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 99ee5c27a9b32e7631347527effa7113c4176d13b74ca46e89e2112174a0f09e
MD5 1f250f66cab53ce94cfbd68ce9293af0
BLAKE2b-256 16b4a30bff21f15dca013bd139966470068df45993c1452a32f29b5870e501b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshdb-0.1.10-py3-none-any.whl:

Publisher: release.yaml on pdxlocations/meshdb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page