From afb3ed129e986d3fa3c42f07db417d8e593b0a38 Mon Sep 17 00:00:00 2001 From: Michael Loveys Date: Sun, 20 Aug 2023 19:45:42 -0500 Subject: [PATCH] initial commit --- p1p-broadcast.py | 36 ++++++++++++++++++++++++++++++++++++ readme.md | 12 ++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 p1p-broadcast.py create mode 100644 readme.md diff --git a/p1p-broadcast.py b/p1p-broadcast.py new file mode 100644 index 0000000..562022f --- /dev/null +++ b/p1p-broadcast.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 + +import sys +import socket + +SSDP_ADDR = "255.255.255.255"; +SSDP_PORT = 2021; + +ssdp_content = "NOTIFY * HTTP/1.1\r\n" + \ + "HOST: 239.255.255.250:1900\r\n" + \ + "Server: Buildroot/2018.02-rc3 UPnP/1.0 ssdpd/1.8\r\n" + \ + "Location: 10.10.10.10\r\n" + \ + "NT: urn:bambulab-com:device:3dprinter:1\r\n" + \ + "USN: 000000000000000\r\n" + \ + "Cache-Control: max-age=1800\r\n" + \ + "DevModel.bambu.com: C11\r\n" + \ + "DevName.bambu.com: 3DP-01S-174\r\n" + \ + "DevSignal.bambu.com: -30\r\n" + \ + "DevConnect.bambu.com: lan\r\n" + \ + "DevBind.bambu.com: free\r\n" + \ + "Devseclink.bambu.com: secure\r\n" + \ + "\r\n" + +ssdp_content = bytes(ssdp_content, 'utf-8') + +sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) +sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + +# Bind to localhost so we send to loopback +sock.bind(('127.0.0.1', 1900)) + +# Set Packet Type to Broadcast +sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) + +# Finally send out the interface +sock.sendto(ssdp_content, (SSDP_ADDR, SSDP_PORT)) diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..5834031 --- /dev/null +++ b/readme.md @@ -0,0 +1,12 @@ +# Broadcast for Bambu P1P Printer + +The python script included was made so I could use Bambu Studio without the need for an internet connection. Additionally, I wanted the printer to be isolated on an IoT vlan with a statically assigned ip address, allowing only necessary traffic. + +For discovery, the printer uses SSDP protocol, and this python script will replicate what the printer sends. + +You will need to replace the following values in the script: + +- `10.10.10.10` with the ip address of the printer +- `000000000000000` with the serial number of the printer + +Once updated, run the script and it will broadcast the packet on the local interface