Nordic UART Service (NUS) BLE logger.
Project description
✨ 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(+coloramaon 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 |
--adv-filter / --no-adv-filter |
Require (default) or disable requiring that the NUS 128-bit UUID appears in advertisement/scan response |
--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.
- Additional Kconfig options (buffer sizes, flow control, etc.) may be required for high log volume or long lines; consult the Zephyr sample: https://docs.zephyrproject.org/latest/samples/subsys/logging/ble_backend/README.html
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. |
| Device not found but is advertising | Your firmware may omit the NUS UUID from advertising data. Retry with --no-adv-filter. |
Advertisement / Scan Response Filtering
By default nus-logger filters discovered devices to only those whose advertising data (including scan responses) lists the Nordic UART Service UUID (6E400001-B5A3-F393-E0A9-E50E24DCCA9E). This reduces false positives when multiple similarly named devices are present.
Some firmware builds intentionally omit 128‑bit service UUIDs to save advertising space. If your device is not being found, disable this filter:
nus-logger --name my-device --no-adv-filter
Platform note: Bleak typically performs active scanning (requesting scan responses). On platforms/backends where only passive advertising data is available, the UUID may also be missing—disabling the filter provides a fallback.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nus_logger-0.2.0.tar.gz.
File metadata
- Download URL: nus_logger-0.2.0.tar.gz
- Upload date:
- Size: 19.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35c567c41098d0877f4323cbd6295a56fc8352d59dce930ca9b86702036c494b
|
|
| MD5 |
617cc6dde5a4b74b0f5cbf799c5cfd0f
|
|
| BLAKE2b-256 |
911d9a942c8b423b6f8599498e7feed35a12d020aff20eb3a34673dfa6c2e0ad
|
Provenance
The following attestation bundles were made for nus_logger-0.2.0.tar.gz:
Publisher:
publish.yml on smnmsr/nus-logger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nus_logger-0.2.0.tar.gz -
Subject digest:
35c567c41098d0877f4323cbd6295a56fc8352d59dce930ca9b86702036c494b - Sigstore transparency entry: 499556550
- Sigstore integration time:
-
Permalink:
smnmsr/nus-logger@b585b1bc867ce82d9e7e732300f682d5a0e3a023 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/smnmsr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b585b1bc867ce82d9e7e732300f682d5a0e3a023 -
Trigger Event:
push
-
Statement type:
File details
Details for the file nus_logger-0.2.0-py3-none-any.whl.
File metadata
- Download URL: nus_logger-0.2.0-py3-none-any.whl
- Upload date:
- Size: 21.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
445de60df5a22cb022b56ce9482b5f059dd37fb10413282a776b865520213c1a
|
|
| MD5 |
7dbbad8dbf5609f21f2676c1ea3f237a
|
|
| BLAKE2b-256 |
cd240d109c07b087af0952536cd7fa496414024494e378716e718f95400d673c
|
Provenance
The following attestation bundles were made for nus_logger-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on smnmsr/nus-logger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nus_logger-0.2.0-py3-none-any.whl -
Subject digest:
445de60df5a22cb022b56ce9482b5f059dd37fb10413282a776b865520213c1a - Sigstore transparency entry: 499556571
- Sigstore integration time:
-
Permalink:
smnmsr/nus-logger@b585b1bc867ce82d9e7e732300f682d5a0e3a023 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/smnmsr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b585b1bc867ce82d9e7e732300f682d5a0e3a023 -
Trigger Event:
push
-
Statement type: