Arduino Router Bridge
A MessagePack-RPC bridge that lets Python applications call methods on an Arduino microcontroller, and expose Python functions the microcontroller can call back. Requires a Unix or TCP socket managed by the Arduino Router and a compatible board such as the Arduino UNO Q or VENTUNO Q.
Installation
pip install arduino-router-bridge
Usage
Create a Bridge, connect it, and use it for as long as you need:
from arduino.router_bridge import Bridge
bridge = Bridge()
bridge.connect() # Returns immediately, connects in the background
bridge.wait_connected(timeout=5) # Optional
# Fire-and-forget notification
bridge.notify("set_led", "green", True)
# Blocking call with response
temperature = bridge.call("get_temperature", "sensor1", timeout=5)
bridge.disconnect()
It can also be used as a context manager:
with Bridge() as bridge:
bridge.call("get_temperature", "sensor1")
Exposing Python functions to the microcontroller
def get_country(lon: str, lat: str) -> str:
return lookup_country(lon, lat)
bridge.provide("get_country", get_country)
Handlers can be provided before or after connecting: they are registered with the router as soon as the connection is available and re-registered transparently whenever it is re-established. Handlers run sequentially on a dedicated thread. A handler may send notifications, but must not call back into the bridge with call(): the peer may be blocked waiting for the handler's own response, so nested calls risk deadlocks and request loops and are rejected with a RuntimeError.
Configuration
The bridge connects to the Arduino RPC router at unix:///var/run/arduino-router.sock by default. Pass an address to the constructor to connect elsewhere; both unix://<path> and tcp://<host>:<port> addresses are supported.
Instances are independent: create one per router you need to talk to. How an instance is shared is the caller's concern; an embedding runtime that needs a process-wide bridge creates one instance at startup and exposes it itself:
from arduino.router_bridge import Bridge
bridge = Bridge() # Uses the default address unix:///var/run/arduino-router.sock
bridge.connect()
Connections are established lazily in the background and reconnected automatically. Disconnect explicitly (or use a context manager) when done; as a safety net, a garbage-collected bridge disconnects automatically.
Security model
The router socket is the trust boundary: any process that can connect to it can invoke the provided methods and forge RPC responses. Unix sockets are protected by file permissions, managed by the Arduino Router. tcp:// connections carry no authentication or encryption: use them only on localhost or an isolated, trusted network, and never expose them to untrusted hosts.
Handler exceptions are reported to the caller by exception type only; full details, including the traceback, stay in the local log. To bound memory usage, incoming messages are capped at 1 MiB and pending handler executions at 1024 by default; both limits are configurable per Bridge.
Logging
The library logs through the standard logging module under the arduino.router_bridge namespace and emits nothing unless the application configures a handler:
import logging
logging.getLogger("arduino.router_bridge").addHandler(logging.StreamHandler())
License
MPL-2.0
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 arduino_router_bridge-0.2.0.tar.gz.
File metadata
- Download URL: arduino_router_bridge-0.2.0.tar.gz
- Upload date:
- Size: 28.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9daa8380c085b556ce7229a105eac2b0eadd9cb75620f1610f9fe387ab656629
|
|
| MD5 |
534780270fa1ba1bcc92041cf2717c32
|
|
| BLAKE2b-256 |
b8a0676680828a2387c8f02d9f02434fb71061f08e08547a02812cdb0ef0fbe0
|
Provenance
The following attestation bundles were made for arduino_router_bridge-0.2.0.tar.gz:
Publisher:
publish.yml on arduino/arduino-router-bridge-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
arduino_router_bridge-0.2.0.tar.gz -
Subject digest:
9daa8380c085b556ce7229a105eac2b0eadd9cb75620f1610f9fe387ab656629 - Sigstore transparency entry: 2669188451
- Sigstore integration time:
-
Permalink:
arduino/arduino-router-bridge-py@0e0ac12d7d15f50fc5e5dcf0662d38126007ad5a -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/arduino
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0e0ac12d7d15f50fc5e5dcf0662d38126007ad5a -
Trigger Event:
push
-
Statement type:
File details
Details for the file arduino_router_bridge-0.2.0-py3-none-any.whl.
File metadata
- Download URL: arduino_router_bridge-0.2.0-py3-none-any.whl
- Upload date:
- Size: 17.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac1123af7d2937b6e9d563070450b39ebff5c6db04e992a5e1bf32cefc50f11d
|
|
| MD5 |
7476199a8b22714b257d351282a57cc0
|
|
| BLAKE2b-256 |
bc3cfac15e422160e50fe4dfdb5ae0cd16e9622f8432b618c0ad4f27929957dc
|
Provenance
The following attestation bundles were made for arduino_router_bridge-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on arduino/arduino-router-bridge-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
arduino_router_bridge-0.2.0-py3-none-any.whl -
Subject digest:
ac1123af7d2937b6e9d563070450b39ebff5c6db04e992a5e1bf32cefc50f11d - Sigstore transparency entry: 2669188500
- Sigstore integration time:
-
Permalink:
arduino/arduino-router-bridge-py@0e0ac12d7d15f50fc5e5dcf0662d38126007ad5a -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/arduino
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0e0ac12d7d15f50fc5e5dcf0662d38126007ad5a -
Trigger Event:
push
-
Statement type: