-
-
Save ozgurgulsuna/7f17df387182869d687d862a45ffc8e8 to your computer and use it in GitHub Desktop.
PowerShell script to make BambuStudio discover a specific printer by IP address, even if it is not on the same subnet (see BambuStudio Issue #702)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Send the IP address of your BambuLab printer to port 2021/udp, which BambuStudio is listens on. | |
# | |
# Ensure your PC has firewall pot 2021/udp open. This is required as the proper response would usually go to the ephemeral source port that the M-SEARCH ssdp:discover message. | |
# But we are are blindly sending a response directly to the BambuStudio listening service port (2021/udp). | |
# | |
# Temporary solution to BambuStudio not allowing you to manually specify the Printer IP. | |
# | |
# Author(s): gashton <https://github.com/gashton>, Fritz webering <https://github.com/fritzw> | |
# | |
param ( | |
[string]$PRINTER_IP = "10.80.2.50" # IP address of your BambuLab Printer | |
) | |
$TARGET_IP="127.0.0.1" # IP address of your PC running BambuStudio. | |
$PRINTER_USN="00M09A381600502" # Printer Serial Number | |
$PRINTER_DEV_MODEL="3DPrinter-X1-Carbon" # Set this to your model (don't know if this is important). | |
$PRINTER_DEV_NAME="IMS-X1C" # Here you can choose any name you want for your printer, which is shown in the slicer. | |
$PRINTER_DEV_SIGNAL="-44" # Good Signal (Artificial), WiFi icon in BambuStudio will appear green with full-bars. | |
$PRINTER_DEV_CONNECT="lan" # LAN Mode | |
$PRINTER_DEV_BIND="free" # Not bound to a Cloud user-account. | |
$remoteudpport=2021 # port to send to | |
$sourceudpport = 0 # SourcePort, maybe empty uses and available port | |
$message = "HTTP/1.1 200 OK`r`nServer: Buildroot/2018.02-rc3 UPnP/1.0 ssdpd/1.8`r`nDate: $(date)`r`nLocation: ${PRINTER_IP}`r`nST: urn:bambulab-com:device:3dprinter:1`r`nEXT:`r`nUSN: ${PRINTER_USN}`r`nCache-Control: max-age=1800`r`nDevModel.bambu.com: ${PRINTER_DEV_MODEL}`r`nDevName.bambu.com: ${PRINTER_DEV_NAME}`r`nDevSignal.bambu.com: ${PRINTER_DEV_SIGNAL}`r`nDevConnect.bambu.com: ${PRINTER_DEV_CONNECT}`r`nDevBind.bambu.com: ${PRINTER_DEV_BIND}`r`n`r`n" | |
$udpClient = new-Object system.Net.Sockets.Udpclient($sourceudpport) | |
$byteBuffer = [System.Text.Encoding]::ASCII.GetBytes($message) | |
$sendbytes = $udpClient.Send($byteBuffer, $byteBuffer.length, $remoteip, $remoteudpport) | |
if ($sendbytes -ne $byteBuffer.length) { | |
write-host "Mismatch bytes" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment