This is the “wireless” portion to round out my full Lightburn control guide, found here:
Since my main snapmaker (pretty much stays setup with the 10W + Enclosure) is far away from my PC, using a cable + Lightburn isn’t an option. I usually just used Luban to start files. However, as many of you know, their software is slow and iffy, so why not bypass it?
Note: Be sure to read all the edits at the end of the post for more info.
There’s a few pre-requisites and I’m setting this up on a windows machine. However, it shouldn’t be too hard to format for a linux machine (mostly changing the bat into an sh and what that entails).
First and foremost; you MUST follow the full Lightburn guide. This method tells the machine to run the gcode file as-is, with no asking about material thickness, origin, etc. You have to have all that setup in the header section of your gcode.
Second, make sure you have curl
, Windows 10/11 should have it built in, if not an installer can be found here: curl for Windows
Open a command prompt and just run curl
and it should spit back curl: try 'curl --help' for more information
if curl is installed.
Third; you will need to find your auth token, this is set when you connect Luban to the snapmaker (and tap the accept connection button on the touchscreen). The snapmaker saves one token and Luban remembers it for sending commands. So you will have to connect with Luban at least once.
To find this, the fastest way is to open a run box with Windows key + R
and input %appdata%\snapmaker-luban
, this will open the luban data folder. You will be looking for a file named machine.json
, open this in any text editor and use the search function ctrl-f
to find “token”. It will be the second one you find, and will be in a “server” block. You will also need the IP address, which is conveniently right there too.
"server": {
"address": "xxx.xxx.xxx.xxx", < Copy the IP here as well.
"token": "1c297775-3dcc-44d0-83f4-b9efad0c81d9", < THIS IS YOUR TOKEN
"isAuto": false,
"name": "snapmaker"
},
After you have your IP and Token, make a new text file named something like “prepare_print.bat”. I’ve also attached one you can edit to this post, unzip it, right click > edit, and change the [IP HERE] and [TOKEN HERE] with your own. Remember to delete the brackets as well.
prepare_print.zip (335 Bytes)
@echo on
curl -X POST "http://[IP HERE]:8080/api/v1/connect?token=[TOKEN HERE]"
curl -X GET "http://[IP HERE]:8080/api/v1/status?token=[TOKEN HERE]&1674308796842"
curl -X POST -F file=@%~1 "http://[IP HERE]:8080/api/v1/prepare_print?token=[TOKEN HERE]&type=Laser"
curl -X POST "http://[IP HERE]:8080/api/v1/connect?token=[TOKEN HERE]"
curl -X GET "http://[IP HERE]:8080/api/v1/status?token=[TOKEN HERE]&1674308796842"
curl -X POST "http://[IP HERE]:8080/api/v1/start_print?token=[TOKEN HERE]"
After saving with your own IP/Token, you’re ready to go. In Lightburn just click Save GCode
and drag & drop your saved .nc
file onto prepare_print.bat
. It will connect to the snapmaker, send the file to the controller, then tell it to start. There’s another connect and some status commands as well, just incase it times out after uploading the file, it reconnects to send the start print command.
EDIT: The touchscreen will show a disconnected from Luban message with a button called stop… Do NOT tap stop on the touchepad. The entire file is sent to the machine before it starts, even if you actually use Luban. It only shows status after starting, you can close Luban entirely and it’ll keep going. Never touch this button.
EDIT2: Speaking of, a fun fact you can do after starting a project is to connect Luban AFTER using the drag/drop. You can see a realtime location and a progress meter incase you wanted to see how much is left just as if you had started via Luban.
EDIT3: It seems with larger files (say >15MB) it disconnects before completing the upload. This is because the snapmaker keeps the connection alive by receiving a status request every few seconds. I don’t know what the ttl is for this, so the solution is to connect Luban and let it keep the connection, or do a status spam until it begins. I’ll see what I can do to mitigate this.
EDIT4: Nevermind, made a keep alive script and attached it below. Start the keep alive, then the project, once the project window disappears (and the project begins) Ctrl-C on the keep alive.
@echo on
curl -X POST "http://[IP HERE]:8080/api/v1/connect?token=[TOKEN HERE]"
:x
curl -X GET "http://[IP HERE]:8080/api/v1/status?token=[TOKEN HERE]&1674308796842"
echo Tap Ctrl+C to stop after the project begins.
timeout /t 2 /nobreak
goto x
KeepAlive.zip (304 Bytes)