Skip to main content

Timestamp Testing Scripts

While testing various presets other than what our main mesh is running, I whipped up this script as a way to spam like a beacon for testing RX and whatnot. The concept is simple, send a message on a timer (set by MM UI) that includes a timestamp and serial to help identify missed messages, message ordering, etc.Β 

I've got two scripts here, one the spam one and the other is an on-demand one I use in MM to have a node reply with the details with a trigger word like dtgtest or something.

timestamp.py

This is the script I ran to run on a 2 minute timer so it would fire off every 2 minutes with the following:

[TEST] YYYY-MM-DD HH:MM:SS MST
Seq xxxxx | Day xx 

The Seq is the number of seconds since midnight, and Day is what number is this day in the full year.

#!/usr/bin/env python3
# mm_meta:
#   name: Connectivity Timestamp
#   emoji: πŸ”’
#   language: Python
"""
Broadcasts a serialized timestamp for mesh connectivity testing.
Intentionally hardcoded to America/Phoenix β€” this node is never leaving AZ.

The sequence number (seconds since midnight) lets receivers detect missed
packets without needing to compare full timestamps.

Scheduled use: Set whatever interval you want to test (e.g. every 5 min).
NOT for normal operations β€” disable this timer when not actively testing.
"""
import json
from datetime import datetime
from zoneinfo import ZoneInfo

def main():
    try:
        tz  = ZoneInfo("America/Phoenix")
        now = datetime.now(tz)

        # Seconds elapsed since local midnight β€” useful for gap detection
        midnight = now.replace(hour=0, minute=0, second=0, microsecond=0)
        seq      = int((now - midnight).total_seconds())

        # Day of year (001–366) for cross-day continuity checks
        day_of_year = now.strftime("%j")

        msg = (
            f"[TEST] {now:%Y-%m-%d %H:%M:%S %Z}\n"
            f"Seq {seq:05d} | Day {day_of_year}"
        )

        print(json.dumps({"response": msg}, ensure_ascii=False))

    except Exception:
        print(json.dumps({"response": ""}))

if __name__ == "__main__":
    main()

mm_dtg_trigger.py

This is the on-demand script variant I use with trigger words in my MM instance. When I send the trigger word in a message, it replies to a specific channel like the above script, but all on one line instead of split.

#!/usr/bin/env python3
# mm_meta:
#   name: DTG Timestamp (On-Demand)
#   emoji: πŸ”’
#   language: Python
"""
Returns a serialized timestamp for on-demand link testing. Trigger this
manually whenever you want a quick snapshot to verify connectivity, message
ordering, or check for gaps in reception.

Format: YYYY-MM-DD HH:MM:SS MST | Seq NNNNN | Day DDD

The sequence number (seconds since midnight) is the key value β€” compare
sequence numbers across multiple triggers to detect missed messages or
estimate delivery latency.

Trigger use: Assign to keyword trigger "dtg" in MM.

Note: Intentionally hardcoded to America/Phoenix. This node lives in AZ.
"""
import json
from datetime import datetime
from zoneinfo import ZoneInfo

def main():
    try:
        tz  = ZoneInfo("America/Phoenix")
        now = datetime.now(tz)

        midnight = now.replace(hour=0, minute=0, second=0, microsecond=0)
        seq      = int((now - midnight).total_seconds())
        day      = now.strftime("%j")

        msg = f"{now:%Y-%m-%d %H:%M:%S %Z} | Seq {seq:05d} | Day {day}"

        print(json.dumps({"response": msg}, ensure_ascii=False))

    except Exception:
        print(json.dumps({"response": ""}))

if __name__ == "__main__":
    main()

Β