bambu-mqtt-comms 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bambu_mqtt_comms/__init__.py +67 -0
- bambu_mqtt_comms/client.py +977 -0
- bambu_mqtt_comms/config.py +41 -0
- bambu_mqtt_comms-0.1.0.dist-info/METADATA +280 -0
- bambu_mqtt_comms-0.1.0.dist-info/RECORD +8 -0
- bambu_mqtt_comms-0.1.0.dist-info/WHEEL +5 -0
- bambu_mqtt_comms-0.1.0.dist-info/licenses/LICENSE +661 -0
- bambu_mqtt_comms-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""
|
|
2
|
+
bambu-mqtt-comms - Python library for raw MQTT communication with Bambu Lab printers.
|
|
3
|
+
|
|
4
|
+
Provides minimal connection management and request/response handling.
|
|
5
|
+
Command formatting and response parsing are handled by the caller (e.g., bambu-mqtt-generator).
|
|
6
|
+
|
|
7
|
+
Example:
|
|
8
|
+
from bambu_mqtt_comms import BambuMQTTClient, PrinterConfig
|
|
9
|
+
|
|
10
|
+
config = PrinterConfig(
|
|
11
|
+
ip="192.168.1.100",
|
|
12
|
+
serial="01S00A123456789",
|
|
13
|
+
access_code="abcdef12",
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
with BambuMQTTClient(config) as client:
|
|
17
|
+
# Send arbitrary JSON, wait for response (matched by sequence_id)
|
|
18
|
+
response = client.send_and_wait({
|
|
19
|
+
"info": {"sequence_id": "20001", "command": "get_version"}
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
# Fire-and-forget
|
|
23
|
+
client.publish({"print": {"sequence_id": "20002", "command": "pause"}})
|
|
24
|
+
|
|
25
|
+
Printers on recent firmware that are not in LAN + Developer mode reject
|
|
26
|
+
unsigned commands. connect() detects that in one round trip without needing
|
|
27
|
+
any credentials, and send_command() signs automatically when a signer was
|
|
28
|
+
supplied and the printer needs it:
|
|
29
|
+
|
|
30
|
+
with BambuMQTTClient(config, signer=my_signer) as client:
|
|
31
|
+
response = client.send_command({"print": {...}})
|
|
32
|
+
if msg := client.signing_status_message():
|
|
33
|
+
print(msg) # None unless the user needs to act
|
|
34
|
+
|
|
35
|
+
Supplying no signer is fully supported and is the common case.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
from .client import (
|
|
39
|
+
BambuMQTTClient,
|
|
40
|
+
BambuMQTTError,
|
|
41
|
+
ConnectionError,
|
|
42
|
+
TimeoutError,
|
|
43
|
+
SignerProtocol,
|
|
44
|
+
SigningState,
|
|
45
|
+
SIGNATURE_REQUIRED_ERR,
|
|
46
|
+
find_err_code,
|
|
47
|
+
)
|
|
48
|
+
from .config import PrinterConfig
|
|
49
|
+
|
|
50
|
+
try:
|
|
51
|
+
from importlib.metadata import PackageNotFoundError, version as _pkg_version
|
|
52
|
+
|
|
53
|
+
__version__ = _pkg_version("bambu-mqtt-comms")
|
|
54
|
+
except PackageNotFoundError: # running from a source tree without installing
|
|
55
|
+
__version__ = "0.0.0+unknown"
|
|
56
|
+
|
|
57
|
+
__all__ = [
|
|
58
|
+
"BambuMQTTClient",
|
|
59
|
+
"PrinterConfig",
|
|
60
|
+
"BambuMQTTError",
|
|
61
|
+
"ConnectionError",
|
|
62
|
+
"TimeoutError",
|
|
63
|
+
"SignerProtocol",
|
|
64
|
+
"SigningState",
|
|
65
|
+
"SIGNATURE_REQUIRED_ERR",
|
|
66
|
+
"find_err_code",
|
|
67
|
+
]
|