Bläddra i källkod

VP: a virtual printer can be an H3C (#3442)

- the H3C (N10) is in the virtual printer's model list; a proxy for an
  H3C takes it from its target
- a virtual H3C gets a serial like a real one (32X99B...): Bambu Studio
  knows an H3C by "32X" (sn_prefix in resources/printers/N10.json)
- the version response names it "H3C"
maziggy 1 vecka sedan
förälder
incheckning
8758adad41

+ 1 - 0
CHANGELOG.md

@@ -11,6 +11,7 @@ All notable changes to Bambuddy will be documented in this file.
 - **Queue several selected files as separate jobs (#3462, requested and contributed by @Eifel-Joe in #3471)** — Selecting several sliced files in the File Manager and pressing **Print** always made them printer alternatives: one queue job, run by the first free printer of a matching model. Two files sliced for the same printer model were refused, so putting several parts into one printer's queue meant printing each file on its own. The print dialog now offers **Alternatives** or **Separate jobs**. Separate jobs puts one queue item per file into the queue, in the order of the list, with the printers (or Any [model]), plate per file, print options, schedule and quantity applying to every item; each item gets its filament mapping at dispatch, against its own file. The dialog picks what fits: two files for the same model start on Separate jobs, with Alternatives unavailable; files for different models start on Alternatives, as before. A version group is still printed as alternatives only. If the queue refuses a file, the files before it stay queued and a second **Print**, also after closing and reopening the dialog, continues with the rest without queueing anything twice. The toolbar button now reads **Print (N files)**. Wiki updated.
 - **Cam Wall tiles show temperatures and finish time, and can pause, stop and switch the light (#3479, sponsor vote Q4 2026)** — With the **Full** status overlay, every connected tile shows its nozzle (both on a dual-nozzle printer), bed and chamber temperatures, and a printing tile adds its finish time beside the time left. Hovering over a tile shows **Pause/Resume** and **Stop**, with the same confirmations as the printer card, and a **chamber light** switch; **Tile controls: Always** in the wall settings keeps them on screen, and a touch screen always shows them. The controls need the `printers:control` permission; a user without it, an offline printer and a Cam Wall token (kiosk) wall get none.
 - **The H2C shows how long each nozzle has printed (#1908, contributed by @Keybored02 in #3507)** — Recent H2C firmware counts the print time of every nozzle, which says more about a nozzle's use than the wear estimate. Hovering over a nozzle on the printer card, in the nozzle rack or on the left and right hotend, now shows its **Print time** next to **Wear**. Firmware that does not report it, and other printers, show no print time. Wiki updated.
+- **A virtual printer can be an H3C (#3442, requested by @mgera-git)** — Settings > Virtual Printer now offers the H3C as a model. Bambu Studio recognises a printer by its serial, so a virtual H3C gets one like a real H3C (32X...). A proxy virtual printer for an H3C takes the model from its target.
 
 ### Changed
 - **SpoolBuddy writes OpenTag3D 2.004 on NTAG215 and NTAG216 tags (#3500, suggested by @pleasantone)** — SpoolBuddy wrote the first version of the OpenTag3D layout. The current version moved every field, so a reader that only knows it read the brand, colour, weight and temperatures from the wrong places. Tags with room for it now get version 2.004, with material, brand, colour name, up to four colours, minimum and maximum print temperature, net weight and empty spool weight. Version 2 no longer fits on an NTAG213, so those keep the first version. SpoolBuddy picks by the size the tag reports, and falls back to the first version if it can't read it; a SpoolBuddy that hasn't been updated keeps writing the first version. Bambuddy does not track density or bed temperature, so a version 2 tag leaves them unset. Wiki updated.

+ 6 - 0
backend/app/services/virtual_printer/manager.py

@@ -68,6 +68,8 @@ VIRTUAL_PRINTER_MODELS = {
     "O1C": "H2C",  # H2C
     "O1C2": "H2C",  # H2C (dual nozzle variant)
     "O1S": "H2S",  # H2S
+    # H3 Series
+    "N10": "H3C",  # H3C
 }
 
 # Serial number prefixes for each model (based on Bambu Lab serial number format)
@@ -105,6 +107,10 @@ MODEL_SERIAL_PREFIXES = {
     # also got the H2D's HMS texts in the slicer.
     "O1C2": "31B8BP",
     "O1S": "09400A",  # H2S
+    # H3 Series
+    # H3C: first 6 characters of a real H3C serial (#3442); Bambu Studio knows
+    # an H3C by "32X" (sn_prefix in resources/printers/N10.json).
+    "N10": "32X99B",
 }
 
 # Reverse mapping: display name → SSDP model code (for auto-inheriting from printer model)

+ 1 - 0
backend/app/services/virtual_printer/mqtt_server.py

@@ -85,6 +85,7 @@ MODEL_PRODUCT_NAMES = {
     "O1C": "H2C",
     "O1C2": "H2C",
     "O1S": "H2S",
+    "N10": "H3C",
 }
 
 

+ 8 - 0
backend/tests/integration/test_virtual_printer_api.py

@@ -741,6 +741,14 @@ class TestVirtualPrinterSerialSurface:
         assert families["O1C2"] == "31B"
         assert families["O1C"] == "094"
 
+    @pytest.mark.asyncio
+    @pytest.mark.integration
+    async def test_the_list_offers_the_h3c(self, async_client: AsyncClient):
+        body = (await async_client.get("/api/v1/virtual-printers")).json()
+
+        assert body["models"]["N10"] == "H3C"
+        assert body["model_serial_prefixes"]["N10"] == "32X"
+
     @pytest.mark.asyncio
     @pytest.mark.integration
     async def test_non_proxy_vp_keeps_self_generated_serial(self, async_client: AsyncClient, printer_factory):

+ 24 - 0
backend/tests/unit/services/test_virtual_printer.py

@@ -4875,6 +4875,30 @@ class TestH2cCodeBySerial:
         assert _get_serial_for_model("O1C", "391800001").startswith("094")
 
 
+class TestH3cVirtualPrinter:
+    """A virtual printer can be an H3C (#3442).
+
+    Bambu Studio knows an H3C by its serial ("32X", sn_prefix in
+    resources/printers/N10.json) and its model code N10.
+    """
+
+    @pytest.mark.parametrize("model", ["H3C", "N10"])
+    def test_the_name_and_the_code_resolve_to_n10(self, model):
+        from backend.app.api.routes.virtual_printers import _resolve_printer_model
+
+        assert _resolve_printer_model(model) == "N10"
+
+    def test_a_proxy_for_an_h3c_takes_its_code(self):
+        from backend.app.services.virtual_printer.manager import model_code_for_printer
+
+        assert model_code_for_printer("H3C", "32X99B000000001") == "N10"
+
+    def test_a_virtual_h3c_has_a_real_h3c_serial(self):
+        from backend.app.services.virtual_printer.manager import _get_serial_for_model
+
+        assert _get_serial_for_model("N10", "391800001").startswith("32X99B")
+
+
 class TestMqttIpRewrite:
     """Tests for TLSProxy._rewrite_mqtt_ip() MQTT packet IP rewriting."""
 

+ 21 - 0
backend/tests/unit/test_vp_mqtt_server.py

@@ -115,6 +115,27 @@ class TestPublishHandlerAdaptiveSerial:
         assert b'"command": "get_version"' in all_bytes
         assert b'"sn": "01P00AABCDEFGHI"' in all_bytes
 
+    def test_a_virtual_h3c_reports_itself_as_an_h3c(self):
+        """#3442: the version response names the model the slicer expects."""
+        server = SimpleMQTTServer(
+            serial="32X99B391800001",
+            access_code="deadbeef",
+            cert_path=Path("/tmp/unused.crt"),  # nosec B108
+            key_path=Path("/tmp/unused.key"),  # nosec B108
+            model="N10",
+        )
+        server._client_serials["c1"] = server.serial
+        writer = MagicMock()
+        writer.write = MagicMock()
+        writer.drain = AsyncMock()
+
+        topic = "device/32X99B391800001/request"
+        payload = _build_publish_payload(topic, {"info": {"command": "get_version", "sequence_id": "7"}})
+        asyncio.run(server._handle_publish(0x30, payload, writer, "c1"))
+
+        all_bytes = b"".join(call.args[0] for call in writer.write.call_args_list)
+        assert b'"product_name": "H3C"' in all_bytes
+
     def test_handle_publish_ignores_non_request_topics(self):
         server = _make_server()
         server._client_serials["c1"] = server.serial