Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
330 commits
Select commit Hold shift + click to select a range
580eb6c
A minor bug fix for OctoPrint.
QuinnDamerell May 2, 2024
0fdaebd
Fixing a few final X1 bugs for the Bambu Lab release!
QuinnDamerell May 3, 2024
fdcf10d
Minor QuickCam fixes.
QuinnDamerell May 3, 2024
0fd4bfc
Fixing a small issue with relative Bambu alternative webcam paths.
QuinnDamerell May 4, 2024
9a8a855
Update install.sh to fix K1 pip cert issues
Guilouz May 12, 2024
40d5ba2
More Creality K1 improvements
Guilouz May 15, 2024
b7d0841
Adding a few more minor K1 install fixes
QuinnDamerell May 15, 2024
2d61792
Lint fix
QuinnDamerell May 15, 2024
554f6e0
Fixng a bug where the 1st and 3rd layer complete commands fire too so…
QuinnDamerell May 15, 2024
ef50344
Version bump
QuinnDamerell May 15, 2024
fb2d46d
Adding an official docker image for Bambu Connect!
QuinnDamerell May 19, 2024
6f1c522
Readme updates
QuinnDamerell May 22, 2024
e631ec4
Adding a little better logging in the Bambu Connect plugin so if the …
QuinnDamerell May 24, 2024
72f0436
Adding a few features to the Bambu Connect installer.
QuinnDamerell May 25, 2024
ddaa7ab
Adding more debug logging for MQTT
QuinnDamerell May 25, 2024
17be074
Debug is too chatty
QuinnDamerell May 25, 2024
0973d16
Updating the Moonraker webcam config logic to handle older Fluidd ins…
QuinnDamerell May 26, 2024
ecb06ba
Adding some testing logic to test DNS resoultion when the main websoc…
QuinnDamerell May 29, 2024
0c76a81
Version bump
QuinnDamerell May 29, 2024
58d9fcd
Adding a little more debug logging to the Bambu connect scanner.
QuinnDamerell May 29, 2024
f6dbe09
Minor logging change.
QuinnDamerell May 30, 2024
efa9cb7
Fixing a small bug not allowing spoolman to work on bambu connect plu…
QuinnDamerell Jun 15, 2024
e1bf31b
Version bump.
QuinnDamerell Jun 15, 2024
87719f8
Publish version tag + docker image tidy (#66)
alec-pinson Jun 15, 2024
dab33d2
Fixing the ARM docker container by adding required deps.
QuinnDamerell Jun 15, 2024
6080c8e
Version bump.
QuinnDamerell Jun 15, 2024
415ed1a
Adding a zstandard as a new optional protocol compression option!
QuinnDamerell Jun 19, 2024
6ea4c68
Minor bug fix.
QuinnDamerell Jun 19, 2024
56a43ea
Converging the install logic to a single thread to prevent packag loc…
QuinnDamerell Jun 19, 2024
70cc996
Adding the start of the logic for Bambu Cloud connecting
QuinnDamerell Jun 25, 2024
7c25222
Updating the Bambu Connect docker image for the new Bambu Cloud setup.
QuinnDamerell Jun 26, 2024
bda5e2d
Final updates to the docker and docker compose docs for Bambu Connect
QuinnDamerell Jun 27, 2024
c21747f
Moving the crypto lib to a an optional lib in the installer.
QuinnDamerell Jun 27, 2024
80b3074
Fix boolean (#68)
spuder Jun 28, 2024
29246e0
Fixing the docker image.
QuinnDamerell Jun 28, 2024
b085be1
Minor fixes to the update and uninstall scripts.
QuinnDamerell Jun 29, 2024
26dce45
Fixing some some installer logging and such.
QuinnDamerell Jun 29, 2024
a672946
Adding back one logging line
QuinnDamerell Jun 29, 2024
0aabdf6
Github action updates
QuinnDamerell Jun 29, 2024
4b42571
Updating the link rules
QuinnDamerell Jun 29, 2024
9b8aacb
Add support for AP07 BambuLabs A1 Mini (#70)
spuder Jun 29, 2024
ef4a05f
Tweaking the linting settings
QuinnDamerell Jun 29, 2024
4d42a5d
Minor debugging edit.
QuinnDamerell Jul 1, 2024
8016a5c
Adding more debug logging.
QuinnDamerell Jul 1, 2024
b501d0a
Adding an os type telemetry message to help debug an issue from support.
QuinnDamerell Jul 4, 2024
ed4ac21
Fixing the OS Type Installer Debug Log
QuinnDamerell Jul 6, 2024
75dd9d3
Fixing the enum to allow it be cast to an int
QuinnDamerell Jul 6, 2024
c192e26
Removing the depdency on the crypo lib, since it causes install issues.
QuinnDamerell Jul 9, 2024
1952416
Version bump
QuinnDamerell Jul 9, 2024
3d90685
Very small bug fix.
QuinnDamerell Jul 9, 2024
4bb40bf
Small change to fix the docker build.
QuinnDamerell Jul 13, 2024
d7b7022
Adding logic provide a device ID in the connection handshake to help …
QuinnDamerell Jul 31, 2024
0e08a9f
Making major perf changes to make things faster and help low power de…
QuinnDamerell Aug 8, 2024
9de7179
Minor static UI changes
QuinnDamerell Aug 11, 2024
33b56db
Adding more docker build flavors
QuinnDamerell Aug 14, 2024
43d7a92
fix str process bug (#74)
arnoliudaxia Aug 17, 2024
e25701f
Fixing various bugs and adding rekey logic.
QuinnDamerell Aug 17, 2024
0c33c80
Adding a bed cooldown notification!
QuinnDamerell Aug 17, 2024
03a181d
Version bump!
QuinnDamerell Aug 17, 2024
1898c76
Removing an annoying log.
QuinnDamerell Aug 17, 2024
e62f2e3
Fixing one more little bed cooldown issue.
QuinnDamerell Aug 17, 2024
4a83118
Adding a config option to control the cooldown temp threshold.
QuinnDamerell Aug 17, 2024
2186b5a
Minor tweaks and a version bump.
QuinnDamerell Aug 17, 2024
df58592
Quick fix for OctoPrint
QuinnDamerell Aug 17, 2024
c7a1d35
Minor bug fixes
QuinnDamerell Aug 22, 2024
7bc7163
Minor bug fixes.
QuinnDamerell Aug 23, 2024
ef3ea05
Disable errors killing the sh script.
QuinnDamerell Aug 31, 2024
0be5d91
Adding more states for Bambu printers to show.
QuinnDamerell Sep 2, 2024
ecef778
Version bump!
QuinnDamerell Sep 3, 2024
4d4b053
Major CPU and memory improments for webcam streaming!
QuinnDamerell Sep 5, 2024
de6cd72
Upgrading to our new websocket lib that have major perf benfits!
QuinnDamerell Sep 6, 2024
71d1a5f
Updating the K1 script to always use the full opkg path.
QuinnDamerell Sep 25, 2024
a0a6f55
Lint fix
QuinnDamerell Sep 25, 2024
270aa70
Making another perf change to add zero copy sends and zero copy reads!
QuinnDamerell Sep 30, 2024
591d370
Reverting out the Bambu Cloud install from the docker readme.
QuinnDamerell Oct 5, 2024
e02d38f
One more update to the docker readme.
QuinnDamerell Oct 5, 2024
2533f68
Fixing a minor bug in the plugin were redirects would cause a client …
QuinnDamerell Nov 4, 2024
2c1e397
Version bump!
QuinnDamerell Nov 4, 2024
7e9b870
Minor logging tweaks
QuinnDamerell Nov 7, 2024
d17a241
Fixing a status input bounds bug.
QuinnDamerell Nov 9, 2024
c4660b3
Updating the debug thread logger with more info.
QuinnDamerell Nov 9, 2024
b5778b1
Adding better logic for unknown http body size reads.
QuinnDamerell Nov 25, 2024
83ccdb2
Update dockerfile to build and run as non root user (#85)
pirish Dec 8, 2024
98dc8ae
Minor edits to the dockerfile.
QuinnDamerell Dec 8, 2024
12a0f13
Updating the bambu docker to make local mode more clear and perfered.
QuinnDamerell Dec 19, 2024
1d22781
Version bump!
QuinnDamerell Dec 20, 2024
9a1b50a
Pulling K1 fix from the OctoApp dev
QuinnDamerell Jan 6, 2025
dc60fed
Updating the socket retry min and max times.
QuinnDamerell Jan 19, 2025
8f827a5
sec: remove log of all env variables (#91)
Yeradon Jan 24, 2025
d083535
Updating the bambu reconnect logic to be less aggressive when trying …
QuinnDamerell Jan 24, 2025
6542fc2
Github actions fix
QuinnDamerell Jan 24, 2025
7c73ba9
Actions change.
QuinnDamerell Jan 24, 2025
92d9d1f
Added tzdata to allow time zone to be set properly. (#93)
jwilson2899 Jan 26, 2025
6258909
Version bump
QuinnDamerell Jan 26, 2025
2475946
Removing the Sentry SDK depdency to fix the new OctoPrint RC.
QuinnDamerell Jan 28, 2025
eedce4a
Enabling Auto Escaped Templates & Version bump.
QuinnDamerell Jan 28, 2025
0bee695
Updating the OctoEverywhere OctoPrint UI pages.
QuinnDamerell Jan 29, 2025
7e3bff5
Fixes issue with assigning variable after thread has already began (#98)
pauljohnston2025 Feb 20, 2025
1c2a0e5
Adding the first pass of support for the K2!
QuinnDamerell Feb 20, 2025
57e34de
Welcome to 4.0 - Adding Support For Elegoo OS printers like the Elego…
QuinnDamerell Mar 2, 2025
624e3f3
Quick bug fix for the elegoo installer.
QuinnDamerell Mar 2, 2025
68b9836
More features and bug fixes!
QuinnDamerell Mar 3, 2025
52fe4db
Updating the docker bootstraps to work for all Klipper/Bambu/Elegoo!
QuinnDamerell Mar 3, 2025
017d96d
A few more Elegoo Connect bug fixes.
QuinnDamerell Mar 3, 2025
1292147
More bug fixes and improvements for Elegoo Connect
QuinnDamerell Mar 4, 2025
220987f
Buggy Mc Bug Fix
QuinnDamerell Mar 4, 2025
be99792
More work and updates for Elegoo Connect!
QuinnDamerell Mar 5, 2025
2ca732b
Quick installer bug fix.
QuinnDamerell Mar 5, 2025
0d73193
Adding two more quick installer updates.
QuinnDamerell Mar 5, 2025
279e614
Final installer tweaks and version bump!
QuinnDamerell Mar 5, 2025
5f1152a
Github readme updates.
QuinnDamerell Mar 5, 2025
e9dae46
Updating the docker readme.
QuinnDamerell Mar 6, 2025
fea9f7f
Minor installer update.
QuinnDamerell Mar 6, 2025
4e35840
Adding Elegoo OS logic to not send response messages to mux sockets t…
QuinnDamerell Mar 8, 2025
7e9cb1c
Disable the K2 install until I can circle back around to it.
QuinnDamerell Mar 9, 2025
f6a1b22
Updating the installer to support the K2!
QuinnDamerell Mar 9, 2025
099a361
Minor installer tweak for the K2
QuinnDamerell Mar 10, 2025
e6dbdd5
Updating the wording for the Elegoo installer manual IP address.
QuinnDamerell Mar 14, 2025
38870d6
More minor installer updates
QuinnDamerell Mar 15, 2025
4035e2a
On more tweak for low powered devices.
QuinnDamerell Mar 15, 2025
896ac11
Adding QR code logic to the installer.
QuinnDamerell Apr 4, 2025
72709c4
Adding logic to move to the Elegoo mainboard MAC since the mainboard …
QuinnDamerell Apr 11, 2025
b67677f
Minor lint fix.
QuinnDamerell Apr 11, 2025
667f4b8
Adding logic in the companion setup and the Klipper Companion docker …
QuinnDamerell Apr 11, 2025
6785efe
Adding the ability to enable debug logging by setting a DEBUG env var.
QuinnDamerell Apr 12, 2025
a8f111e
Adding logic to allow the plugin to attempt to get a oneshot token fr…
QuinnDamerell Apr 13, 2025
093ba28
Fix type hint for _ScanForMoonrakerInstances method to use List inste…
derek-palmer Apr 13, 2025
3323c75
🏗️ Adding a more advanced PY linter and static analysis to catch more…
QuinnDamerell May 3, 2025
cc90963
Quick fix for OctoPrint logging.
QuinnDamerell May 3, 2025
b070305
Minor lint fix.
QuinnDamerell May 3, 2025
4e32f5f
Fix for the Elegoo Neptune 4 Plus
QuinnDamerell May 3, 2025
3f2d223
Fixing a bug with the Elegoo Connector.
QuinnDamerell May 7, 2025
575cffd
Webcam perf fix and a more helpful docker error.
QuinnDamerell May 8, 2025
42c3617
Version bump.
QuinnDamerell May 8, 2025
3ba37c2
Fixing a notification bug
QuinnDamerell May 8, 2025
1ef917d
Version bump
QuinnDamerell May 8, 2025
04a75b4
defect: allow moonraker config to be a link (#105)
hangrymuppet May 15, 2025
13ae6fa
Adding the MQTT proxy and fixing a lot of bugs!
QuinnDamerell May 16, 2025
34df56a
Fixing a minor MQTT proxy socket bug.
QuinnDamerell May 19, 2025
9817a17
Quick fix for multithreaded buffer usage.
QuinnDamerell May 28, 2025
db9c183
Updating the lowest latency server logic to make it more stable with …
QuinnDamerell May 29, 2025
198515b
Adding logic to ensure the octoeverywhere service name remains in the…
QuinnDamerell Jun 22, 2025
8858dfc
Merge branch 'master' of https://github.com/QuinnDamerell/OctoPrint-O…
QuinnDamerell Jun 22, 2025
1e4727b
Adding a minor API update for OctoPrint.
QuinnDamerell Jun 27, 2025
8f82818
Updating the OctoPrint frontend command to use the OctoPrint client t…
QuinnDamerell Jun 27, 2025
6683e62
Adding a Elegoo Centauri Carbon config option to not auto activate th…
QuinnDamerell Jun 27, 2025
5fb0397
Version bump
QuinnDamerell Jun 27, 2025
50ebeaf
Fixing a spammy error log message.
QuinnDamerell Jun 27, 2025
68d694c
Updating the lint rules.
QuinnDamerell Jul 3, 2025
7e7d328
Fix log message for outgoing Bambu MQTT commands
QuinnDamerell Jul 3, 2025
de9b302
Fix OS type detection for Windows
QuinnDamerell Jul 3, 2025
7e06cd2
Adding some small changes from Codex!
QuinnDamerell Jul 3, 2025
d64741a
Lint fix
QuinnDamerell Jul 4, 2025
532271f
Fix minor bugs and typos.
QuinnDamerell Jul 4, 2025
20bfb79
Minor perf update.
QuinnDamerell Jul 4, 2025
f3b5f16
Adding logic to handle newer Bambu printer types.
QuinnDamerell Jul 5, 2025
f17806f
Fix config parsing and env var checks
QuinnDamerell Jul 5, 2025
0ea232d
Updating the network search logic to make it more robust.
QuinnDamerell Jul 6, 2025
fa8e7c4
Improve network search for the Elegoo Centauri
QuinnDamerell Jul 6, 2025
207b7e2
Apply minor improvements
QuinnDamerell Jul 6, 2025
0771ee9
Fix typos and small bugs
QuinnDamerell Jul 6, 2025
20a60bd
Decreasing the elegoo printer scan time.
QuinnDamerell Jul 6, 2025
1ecf7ab
Version bump
QuinnDamerell Jul 6, 2025
a2a3adc
Fixing a docker discovery problem.
QuinnDamerell Jul 6, 2025
4c2d96a
Version bump.
QuinnDamerell Jul 6, 2025
32e628e
Fixing a K2 bug with the service name.
QuinnDamerell Jul 9, 2025
de03e3b
Adding a missing dependency for the installer.
QuinnDamerell Jul 20, 2025
5ca9b10
Adding a link target helper for the docker plugin manager.
QuinnDamerell Jul 23, 2025
7bcf3bb
Adding memory debugging commands
QuinnDamerell Aug 3, 2025
7589c36
Adding a simple local web api to report the plugin's state.
QuinnDamerell Aug 3, 2025
08deaaa
Small buffer optimization.
QuinnDamerell Aug 8, 2025
742b451
Adding logic to delay connection lost notifications for elegoo.
QuinnDamerell Aug 11, 2025
52f7e44
Version bump
QuinnDamerell Aug 11, 2025
540b013
Adding logic to support the local web api in docker.
QuinnDamerell Aug 11, 2025
e4a59b8
Adding a flag to indicate if the plugin is running in docker.
QuinnDamerell Aug 15, 2025
998cff2
Adding a config property to indicate if the plugin is running in Docker.
QuinnDamerell Aug 15, 2025
d773f1a
Bug fix.
QuinnDamerell Aug 15, 2025
97f3276
Lint fix.
QuinnDamerell Aug 15, 2025
80ea41f
Tweaking the WebSocket timeout time.
QuinnDamerell Aug 20, 2025
1ac9965
Update KlipperBootstrap.py (#126)
alexsantos89 Aug 21, 2025
258bb01
Version bump.
QuinnDamerell Aug 21, 2025
a62bfc5
Adding better wording for the Bambu Connect issue.
QuinnDamerell Sep 2, 2025
69fcda5
Adding unique error codes for Bambu.
QuinnDamerell Sep 2, 2025
e5351ee
Lint fixes
QuinnDamerell Sep 2, 2025
693bb6d
Lint fix
QuinnDamerell Sep 2, 2025
f08fa10
feat: make QuickCam `rtsp_transport` configurable (#129)
kldzj Sep 4, 2025
11ac514
Re-enabling sentry for error tracking.
QuinnDamerell Sep 8, 2025
0653931
Adding some exception filtering for common network exceptions.
QuinnDamerell Sep 8, 2025
f83e138
Lint fixes
QuinnDamerell Sep 8, 2025
89b6775
Attempting to fix a fluidd webcam config bug.
QuinnDamerell Sep 9, 2025
64fe17e
Version bump
QuinnDamerell Sep 9, 2025
32084a1
Another attempt to fix the Fluidd webcam detection.
QuinnDamerell Sep 9, 2025
a9372df
Fixing a few Sentry found bugs.
QuinnDamerell Sep 10, 2025
3133451
One more Sentry bug fix.
QuinnDamerell Sep 10, 2025
3ff4018
Version bump!
QuinnDamerell Sep 11, 2025
c206f92
Fixing more minor bugs
QuinnDamerell Sep 15, 2025
85f2181
Updating the Elegoo webcam to not enable the light by default when vi…
QuinnDamerell Sep 21, 2025
38098aa
More typing cleanup.
QuinnDamerell Sep 23, 2025
0f4048d
A fix for the sonic pad
QuinnDamerell Sep 24, 2025
78b34b3
Small fixes to make the Elegoo connection more reliable.
QuinnDamerell Sep 24, 2025
cfb9599
Version bump.
QuinnDamerell Sep 24, 2025
ad7ae0f
Upgrading to the new pyproject.toml system for OctoPrint
QuinnDamerell Jan 8, 2026
0a2976d
Adding pybind11 to our project deps to try to fix an OctoPi issue.
QuinnDamerell Jan 12, 2026
19b9459
Updating the server protocol
QuinnDamerell Jan 15, 2026
2c441cd
Correcting logic for Bambu and Elegoo that handles the connection tar…
QuinnDamerell Jan 15, 2026
ca514c1
Fixing a bug where Bambu error codes didn't get sent properly.
QuinnDamerell Jan 24, 2026
82cb9c5
Lint fix
QuinnDamerell Jan 24, 2026
81e7746
Version bump
QuinnDamerell Jan 26, 2026
daed60d
Fixing a few bugs and adding logic to get the chamber light status.
QuinnDamerell Jan 27, 2026
9980a0e
Adding a command to control the lights.
QuinnDamerell Jan 27, 2026
48b4fed
Version bump
QuinnDamerell Jan 28, 2026
cebf595
Bug fixes for Bambu Lab
QuinnDamerell Jan 28, 2026
4a04ddc
Version bump!
QuinnDamerell Jan 28, 2026
56245d2
Adding support for the Snapmaker U1
QuinnDamerell Jan 30, 2026
53a62f6
Lint fix.
QuinnDamerell Jan 30, 2026
506d21a
More lint fixes
QuinnDamerell Jan 30, 2026
d67e52f
Lint fix!
QuinnDamerell Jan 30, 2026
d980037
Version bump!
QuinnDamerell Jan 30, 2026
5f64cd4
A quick fix for the moonraker config file, allowing the host:all sett…
QuinnDamerell Jan 31, 2026
3245954
Version bump!
QuinnDamerell Jan 31, 2026
122610b
Adding a account linking URL log line that's easy to grep.
QuinnDamerell Feb 2, 2026
47ec5b2
Another small Snapmaker U1 tweak.
QuinnDamerell Feb 2, 2026
d6500e1
Converting all debug log lines to use lazy formatting for perf.
QuinnDamerell Feb 3, 2026
51077f1
Lint fixes
QuinnDamerell Feb 3, 2026
59656ea
Minor tweaks and trying to stabilize the first and third layer notifi…
QuinnDamerell Feb 3, 2026
20a2461
Attempting some changes to reduce the plugin's memory and fix possibl…
QuinnDamerell Feb 3, 2026
f7990d9
Lint fixes.
QuinnDamerell Feb 3, 2026
627c57f
More lint fixes
QuinnDamerell Feb 3, 2026
f4a6b3a
More lint fixes.
QuinnDamerell Feb 3, 2026
d6779c2
I'm about to disable this linter.
QuinnDamerell Feb 3, 2026
42d5f96
Sigh.
QuinnDamerell Feb 3, 2026
7f27ac7
Version bump.
QuinnDamerell Feb 3, 2026
ba9085d
Adding moonraker support for the lights APIs and updating them to sup…
QuinnDamerell Feb 4, 2026
13d6fe9
Lint fixes
QuinnDamerell Feb 4, 2026
58da1b0
Adding new commands for printer control
QuinnDamerell Feb 4, 2026
3aa417a
Adding some memory flags to the service files to prevent PY from eati…
QuinnDamerell Feb 4, 2026
2fbae36
Adding a feature control flag for each platform.
QuinnDamerell Feb 4, 2026
70fe825
Version bump!
QuinnDamerell Feb 4, 2026
a242d09
Fixing a memory leak and adding a lot of logic to help low-memory dev…
QuinnDamerell Feb 5, 2026
b918338
Lint fixes.
QuinnDamerell Feb 5, 2026
f5811cc
Version bump!
QuinnDamerell Feb 5, 2026
19c73aa
Adding a few more websocket optimizations.
QuinnDamerell Feb 15, 2026
a4356e0
Lint fix
QuinnDamerell Feb 15, 2026
8696a01
Version bump
QuinnDamerell Feb 15, 2026
b08a6d2
Fixing a few minor issues that could cause major hangs.
QuinnDamerell Feb 19, 2026
cf77610
Version bump
QuinnDamerell Feb 19, 2026
22ed9c7
Fixing a logging bug
QuinnDamerell Apr 12, 2026
e1d4685
Merge upstream OctoEverywhere
crysxd Apr 17, 2026
49f2fda
Record merge of upstream OctoEverywhere
crysxd Apr 17, 2026
c99a5ba
Fix pylint C0411 wrong-import-order in dnstest, httpsessions, mdns
crysxd Apr 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions bambu_octoapp/bambuclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import time
import json
import socket
import logging
import threading
from typing import Any, Dict, List, Optional

Expand Down Expand Up @@ -34,7 +35,7 @@ class BambuClient:
_Instance:"BambuClient" = None #pyright: ignore[reportAssignmentType]

# Useful for debugging.
_PrintMQTTMessages = True
_PrintMQTTMessages = False

@staticmethod
def Init(logger:LoggerLike, config:Config, stateTranslator:IBambuStateTranslator) -> None:
Expand Down Expand Up @@ -75,6 +76,8 @@ def __init__(self, logger:LoggerLike, config:Config, stateTranslator:IBambuState

# We use this var to keep track of consecutively failed connections
self.ConsecutivelyFailedConnectionAttempts = 0
# This flag indicates if we have tried a network scan since the plugin started. If not, we should do it again.
self.HasDoneNetScanSincePluginStart = False

# Start a thread to setup and maintain the connection.
self.CurrentConnectionContext:Optional[ConnectionContext] = None
Expand Down Expand Up @@ -287,7 +290,15 @@ def _OnDisconnect(self, client:Any, userdata:Any, disconnect_flags:Any, reason_c
# So if we were pending a subscribe call, give the user a better error message so they know the likely cause.
if self.IsPendingSubscribe:
self.Logger.error("Bambu printer mqtt connection lost when trying to sub for events.")
self.Logger.error(f"THIS USUALLY MEANS THE PRINTER SERIAL NUMBER IS WRONG. We tried to use the serial number '{self.PrinterSn}'. Double check the SN is correct.")
self.Logger.error("")
self.Logger.error("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
self.Logger.error("This might indicate the printer ACCESS CODE - OR - SERIAL NUMBER IS WRONG.")
self.Logger.error(f" Current Serial Number: '{self.PrinterSn}'")
self.Logger.error(f" Current Access Code: '{self.LanAccessCode}'")
self.Logger.error("")
self.Logger.error("Check these values match your printer. If they changed, run the OctoApp installer again to update them or update your Docker configuration.")
self.Logger.error("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
self.Logger.error("")
else:
self.Logger.warning("Bambu printer connection lost. We will try to reconnect in a few seconds.")
# Clear the state since we lost the connection and won't stay synced.
Expand Down Expand Up @@ -342,7 +353,7 @@ def _OnMessage(self, client:Any, userdata:Any, mqttMsg:mqtt.MQTTMessage) -> None
raise Exception("Parsed json MQTT message returned None")

# Print for debugging if desired.
if BambuClient._PrintMQTTMessages:
if BambuClient._PrintMQTTMessages and self.Logger.isEnabledFor(logging.DEBUG):
self.Logger.debug("Incoming Bambu Message:\r\n"+json.dumps(msg, indent=3))

# Since we keep a track of the state locally from the partial updates, we need to feed all updates to our state object.
Expand Down Expand Up @@ -433,7 +444,8 @@ def _GetConnectionContextToTry(self, isConnectAttemptFromEventBump:bool) -> Conn
if isConnectAttemptFromEventBump is False:
self.ConsecutivelyFailedConnectionAttempts += 1
doPrinterSearch = False
if self.ConsecutivelyFailedConnectionAttempts > 6:
# We only search every now and then, unless this is one of the first connect attempts after the plugin started.
if (self.HasDoneNetScanSincePluginStart is False and self.ConsecutivelyFailedConnectionAttempts > 1) or self.ConsecutivelyFailedConnectionAttempts > 6:
self.ConsecutivelyFailedConnectionAttempts = 0
doPrinterSearch = True

Expand Down Expand Up @@ -468,7 +480,8 @@ def _GetConnectionContextToTry(self, isConnectAttemptFromEventBump:bool) -> Conn
self.Logger.info(f"Searching for your Bambu Lab printer {self.PrinterSn}")
if self.LanAccessCode is None:
return self._GetLocalConnectionContext(configIpOrHostname)
ips = NetworkSearch.ScanForInstances_Bambu(self.Logger, self.LanAccessCode, self.PrinterSn, threadCount=25, delaySec=0.2)
self.HasDoneNetScanSincePluginStart = True
ips = NetworkSearch.ScanForInstances_Bambu(self.Logger, self.LanAccessCode, self.PrinterSn, ipHint=configIpOrHostname, threadCount=25, delaySec=0.2)

# If we get an IP back, it is the printer.
# The scan above will only return an IP if the printer was successfully connected to, logged into, and fully authorized with the Access Token and Printer SN.
Expand Down
1 change: 1 addition & 0 deletions bambu_octoapp/bambumodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class BambuHmsEntry(NamedTuple):
class BambuPrintErrors(Enum):
Unknown = 1 # This will be most errors, since most of them aren't mapped
FilamentRunOut = 2
PrintFailureDetected = 3 # The Bambu AI detected a failure.


# Since MQTT syncs a full state and then sends partial updates, we keep track of the full state
Expand Down
7 changes: 5 additions & 2 deletions bambu_octoapp/bambustatetranslater.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,11 @@ def BambuOnPauseOrTempError(self, bambuState:BambuState) -> None:
self.NotificationsHandler.OnFilamentChange()
return

# Send a generic error.
self.NotificationsHandler.OnUserInteractionNeeded()
# Send the error string from the bambu API map.
errorStr = bambuState.GetFileNameWithNoExtension()
if errorStr is None:
errorStr = "General Error"
self.NotificationsHandler.OnError(errorStr)


def BambuOnResume(self, bambuState:BambuState) -> None:
Expand Down
24 changes: 23 additions & 1 deletion elegoo_octoapp/elegoostatetranslater.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import threading
from typing import Optional, Tuple

from octoapp.logging import LoggerLike
from octoapp.notificationshandler import NotificationsHandler
from octoapp.interfaces import IPrinterStateReporter
from octoapp.util.delayedcallback import DelayedCallback

from .elegooclient import ElegooClient
from .elegoomodels import PrinterState
Expand All @@ -14,11 +16,16 @@
# and to act as the printer state interface for Bambu printers.
class ElegooStateTranslator(IPrinterStateReporter, IStateTranslator):

# The amount of time we will wait for a reconnect before we fire the disconnected notification.
c_ConnectionLostNotificationDelaySec = 10.0

def __init__(self, logger:LoggerLike) -> None:
self.Logger = logger
self.NotificationsHandler:NotificationsHandler = None #pyright: ignore[reportAttributeAccessIssue]
self.LastStatus:Optional[str] = None
self.IsWaitingOnPrintInfoToFirePrintStart = False
self.DelayedConnectionLostCallback:Optional[DelayedCallback] = None
self.DelayedConnectionLostCallbackLock = threading.Lock()


def SetNotificationHandler(self, notificationHandler:NotificationsHandler):
Expand All @@ -32,18 +39,33 @@ def OnConnectionLost(self, wasFullyConnected:bool) -> None:
# If we were fully connected and were printing or warming up, then report the connection loss.
# Otherwise, don't bother, since it might just be the user turning off the printer.
if wasFullyConnected and (PrinterState.IsPrepareOrSlicingState(self.LastStatus) or PrinterState.IsPrintingState(self.LastStatus, False)):
self.NotificationsHandler.OnError("Connection to printer lost during a print.")
# There seems to be a bug while printing where we will get disconnected from the printer's server but then reconnected with no effect on the print.
# To combat spammy notifications, we use a delayed callback to only fire after we know we have been disconnected for some time.
with self.DelayedConnectionLostCallbackLock:
if self.DelayedConnectionLostCallback is not None:
self.DelayedConnectionLostCallback.Cancel()
self.DelayedConnectionLostCallback = DelayedCallback.Create(self.Logger, "ElegooDelayedConnectionLostCallback", self.c_ConnectionLostNotificationDelaySec, self._DelayedConnectionLostCallback)

# Always reset our state.
self.LastStatus = None
self.IsWaitingOnPrintInfoToFirePrintStart = False


def _DelayedConnectionLostCallback(self):
self.NotificationsHandler.OnError("Connection to printer lost during a print.")


# Fired when any mqtt message comes in.
# State will always be NOT NONE, since it's going to be created before this call.
# The isFirstFullSyncResponse flag indicates if this is the first full state sync of a new connection.
def OnStatusUpdate(self, pState:PrinterState, isFirstFullSyncResponse:bool) -> None:

# Ensure if we have a connection lost delay in progress, cancel it since we're back.
with self.DelayedConnectionLostCallbackLock:
if self.DelayedConnectionLostCallback is not None:
self.DelayedConnectionLostCallback.Cancel()
self.DelayedConnectionLostCallback = None

# First, if we have a new connection and we just synced, make sure the notification handler is in sync.
if isFirstFullSyncResponse:
self.NotificationsHandler.OnRestorePrintIfNeeded(pState.IsPrinting(False), pState.IsPaused(), pState.GetPrintCookie())
Expand Down
9 changes: 7 additions & 2 deletions moonraker_octoapp/moonrakerclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,12 @@ def _OnWsNonResponseMessage(self, msg:Dict[str, Any]) -> None:
jobObj = jobContainerObj["job"]
filename = jobObj.get("filename", None)
if filename is not None:
self.MoonrakerCompat.OnPrintStart(filename)
self.DownloadFileForProcessing(filename)
# Note sometimes the filename can just be ""
if len(filename) == 0:
self.Logger.info("Moonraker client detected print start with no file name, so we aren't firing the print started event.")
else:
self.MoonrakerCompat.OnPrintStart(filename)
self.DownloadFileForProcessing(filename)
return
elif action == "finished":
# This can be a finish canceled or failed.
Expand Down Expand Up @@ -560,6 +564,7 @@ def RunBlocking(self) -> None:
onWsClose=self._onWsClose,
onWsError=self._onWsError
)
self.WebSocket.SetDisableCertCheck(True)

# Run until the socket closes
# When it returns, ensure it's closed.
Expand Down
159 changes: 159 additions & 0 deletions octoapp/Proto/HandshakeAck.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
# automatically generated by the FlatBuffers compiler, do not modify

# namespace: Proto

import octoflatbuffers
from typing import Any
from typing import Optional
class HandshakeAck(object):
__slots__ = ['_tab']

@classmethod
def GetRootAs(cls, buf, offset: int = 0):
n = octoflatbuffers.encode.Get(octoflatbuffers.packer.uoffset, buf, offset)
x = HandshakeAck()
x.Init(buf, n + offset)
return x

@classmethod
def GetRootAsHandshakeAck(cls, buf, offset=0):
"""This method is deprecated. Please switch to GetRootAs."""
return cls.GetRootAs(buf, offset)
# HandshakeAck
def Init(self, buf: bytes, pos: int):
self._tab = octoflatbuffers.table.Table(buf, pos)

# HandshakeAck
def Accepted(self):
o = octoflatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
if o != 0:
return bool(self._tab.Get(octoflatbuffers.number_types.BoolFlags, o + self._tab.Pos))
return False

# HandshakeAck
def ConnectedAccounts(self, j: int):
o = octoflatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
if o != 0:
a = self._tab.Vector(o)
return self._tab.String(a + octoflatbuffers.number_types.UOffsetTFlags.py_type(j * 4))
return ""

# HandshakeAck
def ConnectedAccountsLength(self) -> int:
o = octoflatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
if o != 0:
return self._tab.VectorLen(o)
return 0

# HandshakeAck
def ConnectedAccountsIsNone(self) -> bool:
o = octoflatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
return o == 0

# HandshakeAck
def Error(self) -> Optional[str]:
o = octoflatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
if o != 0:
return self._tab.String(o + self._tab.Pos)
return None

# HandshakeAck
def BackoffSeconds(self):
o = octoflatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
if o != 0:
return self._tab.Get(octoflatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
return 0

# HandshakeAck
def RequiresPluginUpdate(self):
o = octoflatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
if o != 0:
return bool(self._tab.Get(octoflatbuffers.number_types.BoolFlags, o + self._tab.Pos))
return False

# HandshakeAck
def Octokey(self) -> Optional[str]:
o = octoflatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
if o != 0:
return self._tab.String(o + self._tab.Pos)
return None

# HandshakeAck
def RsaChallengeResult(self) -> Optional[str]:
o = octoflatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
if o != 0:
return self._tab.String(o + self._tab.Pos)
return None

# HandshakeAck
def RequiresRekey(self):
o = octoflatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
if o != 0:
return bool(self._tab.Get(octoflatbuffers.number_types.BoolFlags, o + self._tab.Pos))
return False

def HandshakeAckStart(builder: octoflatbuffers.Builder):
builder.StartObject(8)

def Start(builder: octoflatbuffers.Builder):
HandshakeAckStart(builder)

def HandshakeAckAddAccepted(builder: octoflatbuffers.Builder, accepted: bool):
builder.PrependBoolSlot(0, accepted, 0)

def AddAccepted(builder: octoflatbuffers.Builder, accepted: bool):
HandshakeAckAddAccepted(builder, accepted)

def HandshakeAckAddConnectedAccounts(builder: octoflatbuffers.Builder, connectedAccounts: int):
builder.PrependUOffsetTRelativeSlot(1, octoflatbuffers.number_types.UOffsetTFlags.py_type(connectedAccounts), 0)

def AddConnectedAccounts(builder: octoflatbuffers.Builder, connectedAccounts: int):
HandshakeAckAddConnectedAccounts(builder, connectedAccounts)

def HandshakeAckStartConnectedAccountsVector(builder, numElems: int) -> int:
return builder.StartVector(4, numElems, 4)

def StartConnectedAccountsVector(builder, numElems: int) -> int:
return HandshakeAckStartConnectedAccountsVector(builder, numElems)

def HandshakeAckAddError(builder: octoflatbuffers.Builder, error: int):
builder.PrependUOffsetTRelativeSlot(2, octoflatbuffers.number_types.UOffsetTFlags.py_type(error), 0)

def AddError(builder: octoflatbuffers.Builder, error: int):
HandshakeAckAddError(builder, error)

def HandshakeAckAddBackoffSeconds(builder: octoflatbuffers.Builder, backoffSeconds: int):
builder.PrependUint64Slot(3, backoffSeconds, 0)

def AddBackoffSeconds(builder: octoflatbuffers.Builder, backoffSeconds: int):
HandshakeAckAddBackoffSeconds(builder, backoffSeconds)

def HandshakeAckAddRequiresPluginUpdate(builder: octoflatbuffers.Builder, requiresPluginUpdate: bool):
builder.PrependBoolSlot(4, requiresPluginUpdate, 0)

def AddRequiresPluginUpdate(builder: octoflatbuffers.Builder, requiresPluginUpdate: bool):
HandshakeAckAddRequiresPluginUpdate(builder, requiresPluginUpdate)

def HandshakeAckAddOctokey(builder: octoflatbuffers.Builder, octokey: int):
builder.PrependUOffsetTRelativeSlot(5, octoflatbuffers.number_types.UOffsetTFlags.py_type(octokey), 0)

def AddOctokey(builder: octoflatbuffers.Builder, octokey: int):
HandshakeAckAddOctokey(builder, octokey)

def HandshakeAckAddRsaChallengeResult(builder: octoflatbuffers.Builder, rsaChallengeResult: int):
builder.PrependUOffsetTRelativeSlot(6, octoflatbuffers.number_types.UOffsetTFlags.py_type(rsaChallengeResult), 0)

def AddRsaChallengeResult(builder: octoflatbuffers.Builder, rsaChallengeResult: int):
HandshakeAckAddRsaChallengeResult(builder, rsaChallengeResult)

def HandshakeAckAddRequiresRekey(builder: octoflatbuffers.Builder, requiresRekey: bool):
builder.PrependBoolSlot(7, requiresRekey, 0)

def AddRequiresRekey(builder: octoflatbuffers.Builder, requiresRekey: bool):
HandshakeAckAddRequiresRekey(builder, requiresRekey)

def HandshakeAckEnd(builder: octoflatbuffers.Builder) -> int:
return builder.EndObject()

def End(builder: octoflatbuffers.Builder) -> int:
return HandshakeAckEnd(builder)
15 changes: 14 additions & 1 deletion octoapp/Proto/HandshakeSyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,15 @@ def DeviceId(self) -> Optional[str]:
return self._tab.String(o + self._tab.Pos)
return None

# HandshakeSyn
def IsDockerContainer(self):
o = octoflatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(40))
if o != 0:
return bool(self._tab.Get(octoflatbuffers.number_types.BoolFlags, o + self._tab.Pos))
return False

def HandshakeSynStart(builder: octoflatbuffers.Builder):
builder.StartObject(18)
builder.StartObject(19)

def Start(builder: octoflatbuffers.Builder):
HandshakeSynStart(builder)
Expand Down Expand Up @@ -296,6 +303,12 @@ def HandshakeSynAddDeviceId(builder: octoflatbuffers.Builder, deviceId: int):
def AddDeviceId(builder: octoflatbuffers.Builder, deviceId: int):
HandshakeSynAddDeviceId(builder, deviceId)

def HandshakeSynAddIsDockerContainer(builder: octoflatbuffers.Builder, isDockerContainer: bool):
builder.PrependBoolSlot(18, isDockerContainer, 0)

def AddIsDockerContainer(builder: octoflatbuffers.Builder, isDockerContainer: bool):
HandshakeSynAddIsDockerContainer(builder, isDockerContainer)

def HandshakeSynEnd(builder: octoflatbuffers.Builder) -> int:
return builder.EndObject()

Expand Down
Loading
Loading