Skip to main content

Nordic UART Service (NUS) BLE logger.

Project description

NUS Logger

Nordic UART Service (NUS) BLE log collector for Zephyr / nRF Connect SDK devices.

PyPI CI Python Versions License: MIT BLE Status


✨ Highlights

  • Zero‑config CLI: discover, connect, stream logs in one command.
  • Resilient: automatic reconnect to the same device after link loss (disable with --no-reconnect).
  • Readable timestamps: UTC (--ts) or local (--ts-local).
  • Dual view: optional raw hex alongside decoded UTF‑8 text (--raw).
  • Log persistence: safe append mode (rotation‑friendly) to any file.
  • Cross‑platform: Windows / macOS / Linux using native Bluetooth via bleak.
  • Library friendly: small, typed API (NUSClient, NUSLoggerController).
  • Dependency‑light: just bleak (+ colorama on Windows for color support).

Installation

pip install nus-logger

Requires Python 3.9+.

Upgrade in place:

pip install -U nus-logger

Quick Start (CLI)

# 1. Zero-config interactive wizard (scan, pick device, choose options)
nus-logger

# 2. List advertising NUS devices (non-interactive)
nus-logger --list

# 3. Connect by (partial) name, show UTC timestamps, also log to file
nus-logger --name my-device --ts --logfile logs/session.txt

# 4. Show local timestamps and raw hex dump
nus-logger --name my-device --ts-local --raw

Module mode (equivalent):

python -m nus_logger --name my-device --ts

Press Ctrl-C to stop. By default the tool will auto‑reconnect after an unexpected disconnect; use --no-reconnect to revert to single‑session behaviour.

CLI Reference

Environment variables override flags when corresponding flags are omitted.

Flag Description
-h, --help Show CLI help
--wizard Interactive scan & option wizard (default when no args)
--list List visible devices then exit
--name SUBSTR Match advertising name
--filter-addr SUBSTR Prefer address containing substring
--ts / --ts-local Add UTC or local timestamps (mutually exclusive)
--raw Show hex bytes
--logfile PATH Append decoded lines to file (relative or absolute path)
--timeout SECS Scan / connect timeout
--verbose Dump discovered GATT structure once
--reconnect, --no-reconnect Automatically rescan & reconnect after disconnect (default: enabled)

Typical Workflow (Zephyr / nRF Connect)

To stream the Zephyr logging subsystem over BLE for nus-logger to consume you should enable the BLE logging backend with CONFIG_LOG_BACKEND_BLE=y. The backend handles formatting, buffering and transport so normal LOG_INF()/LOG_ERR() etc. arrive as text lines.

Troubleshooting

Situation Hint
No devices on Windows Toggle Bluetooth off/on or airplane mode, verify advertising.
Linux permission errors Ensure user in bluetooth group or grant CAP_NET_RAW to Python binary.
macOS permission prompt Allow Bluetooth access in System Settings > Privacy & Security > Bluetooth.
Disconnects Reduce distance / interference.
Mixed devices with similar names Use --filter-addr to prefer a known address substring.

Development

git clone https://github.com/smnmsr/nus-logger.git
cd nus-logger
pip install -e .[dev]
pytest

Linting is intentionally minimal; contributions should keep the code small and dependency‑light.

Versioning & Compatibility

The public surface is the CLI plus the NUSClient / NUSLoggerController classes. Minor releases may add kwargs/features; removals will occur only in a major bump following semantic versioning principles.

License

MIT License © 2025 Simon M. See LICENSE file for full text.


If this saves you time, a ⭐ on GitHub helps others discover it.

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

nus_logger-0.1.3.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

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

nus_logger-0.1.3-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file nus_logger-0.1.3.tar.gz.

File metadata

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

File hashes

Hashes for nus_logger-0.1.3.tar.gz
Algorithm Hash digest
SHA256 8bedd6a159e32ad8935800ff68856dc10434a7c09d2d713165dc1a34b92e45d6
MD5 3c998c009f082528779beb97f41ff8a5
BLAKE2b-256 e1a0dfa79b254f35cd98e5105dcfea8f73d3f3b542ad54deb877666ce51bb931

See more details on using hashes here.

Provenance

The following attestation bundles were made for nus_logger-0.1.3.tar.gz:

Publisher: publish.yml on smnmsr/nus-logger

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

File details

Details for the file nus_logger-0.1.3-py3-none-any.whl.

File metadata

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

File hashes

Hashes for nus_logger-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ea0d1451b0c1d53dbc03d66900bb56b1784ea72761018f516fb2dc7121fb7440
MD5 860ec127a9a6d912a4aff95b85d6e554
BLAKE2b-256 2f6365f2db81e13c6498230d9941e29eec7b77d3a30dac6a5e336733c4040285

See more details on using hashes here.

Provenance

The following attestation bundles were made for nus_logger-0.1.3-py3-none-any.whl:

Publisher: publish.yml on smnmsr/nus-logger

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