This is mainly for the wireless console, but I have a bonus, ridiculous way to run projects completely wirelessly without even poking the button on the XTool! So let’s get into it!
If you’ve caught anything I’ve done on the Snapmaker forum, I’ve been full in on fully automatic control and setup. As such, I’ve figured out a lot of hacky ways to use the web API. Which is how I found out how to send files to the XTool D1 Pro via wifi, that can be found here;
I recently was using wireshark to watch the interactions between XCS and the D1, and I came across cmd?cmd=
as an HTTP get command. This what the entrypoint I needed, it lets me send gcode lines over http via curl! So I came up with the following;
@echo off
:a
set /p code=gcode to send:
curl -X GET "http://xxx.xxx.xxx.xxx:8080/cmd?cmd=%code%"
goto :a
Save this as a .bat
file, something like XToolConsole.bat
after replacing xxx.xxx.xxx.xxx
with your D1’s IP address, which can be found in XCS. Double-click to run the .bat and it’ll open a command prompt with the following;
gcode to send:
input your gcode command with no spaces and it’ll send it to the D1 and you should get an ok
response.
gcode to send:$H
{"result":"ok"}gcode to send:
This could possibly be the start of full wifi control in Lightburn if they decide to implement.
Now for the ridiculous…
@echo on
setlocal enableextensions disabledelayedexpansion
set "search= "
set "replace="
set "textFile=%~1"
for /f "delims=" %%i in ('type "%textFile%" ^& break ^> "%textFile%" ') do (
set "line=%%i"
setlocal enabledelayedexpansion
>>"%textFile%" echo(!line:%search%=%replace%!
endlocal
)
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in (%~1) do (
echo curl -X GET "http://xxx.xxx.xxx.xxx:8080/cmd?cmd=%%a" >>%textFile%.bat
)
Replacing the IP and saving as a .bat
file lets you save the gcode file, then drag/drop onto this .bat file and it’ll strip all comments and spaces from the gcode, then add a curl get command to each line, and spit the entire program out as a savedname.nc.bat
file. It takes forever doing it this way, so a post-processor or other method that’s faster would be preferred. Running the resulting file will basically DDoS your D1 with curl commands for each and every line of gcode.
Result? It actually does the engrave. Is it practical? Not really. You’re better off using my sender and then slapping the button, but as a proof of concept it was a fun project.
Overall, I figured the wireless console to send gcode commands over wifi would be something people could use, and maybe give the Lightburn team some ideas. It’s something the official software doesn’t even do, so there’s that. Can be handy to troubleshoot homing/movement issues and the like. Enjoy.