Table of Contents

Class RepRapFirmwareController

Namespace
DuetWebServer.Controllers
Assembly
DuetWebServer.dll

MVC Controller for /rr_ requests

[ApiController]
[Authorize(Policy = "readOnly")]
[Route("/")]
public class RepRapFirmwareController : ControllerBase
Inheritance
RepRapFirmwareController
Inherited Members

Remarks

Create a new controller instance

Constructors

RepRapFirmwareController(IConfiguration, ILogger<RepRapFirmwareController>, IModelProvider)

MVC Controller for /rr_ requests

public RepRapFirmwareController(IConfiguration configuration, ILogger<RepRapFirmwareController> logger, IModelProvider modelProvider)

Parameters

configuration IConfiguration

Launch configuration

logger ILogger<RepRapFirmwareController>

Logger instance

modelProvider IModelProvider

Model provider

Remarks

Create a new controller instance

Methods

Connect(string?, ISessionStorage)

GET /rr_connect?password={password} Attempt to create a new connection and log in using the (optional) password The extra "time" parameter is currently ignored in SBC mode

[AllowAnonymous]
[HttpGet("rr_connect")]
public Task<IActionResult> Connect(string? password, ISessionStorage sessionStorage)

Parameters

password string

Password to check

sessionStorage ISessionStorage

Session storage singleton

Returns

Task<IActionResult>

HTTP status code: (200) JSON response

CreateDirectory(string?)

GET /rr_mkdir?dir={dir} Create the given directory.

[Authorize(Policy = "readWrite")]
[HttpGet("rr_mkdir")]
public Task<IActionResult> CreateDirectory(string? dir)

Parameters

dir string

Directory to create

Returns

Task<IActionResult>

HTTP status code: (200) JSON response

DeleteFileOrDirectory(string?)

GET /rr_delete?name={filename} Delete the given file or directory.

[Authorize(Policy = "readWrite")]
[HttpGet("rr_delete")]
public Task<IActionResult> DeleteFileOrDirectory(string? name)

Parameters

name string

File or directory to delete

Returns

Task<IActionResult>

HTTP status code: (200) JSON response

Disconnect(ISessionStorage)

GET /rr_disconnect Disconnect again from the RepRapFirmware controller

[AllowAnonymous]
[HttpGet("rr_disconnect")]
public Task<IActionResult> Disconnect(ISessionStorage sessionStorage)

Parameters

sessionStorage ISessionStorage

Session storage singleton

Returns

Task<IActionResult>

HTTP status code: (200) JSON response

DoCode(string?)

GET /rr_gcode?gcode={gcode} Execute plain G/M/T-code(s) from the request body and return the G-code response when done.

[HttpGet("rr_gcode")]
[Authorize(Policy = "readWrite")]
public Task<IActionResult> DoCode(string? gcode)

Parameters

gcode string

G-code(s) to execute

Returns

Task<IActionResult>

HTTP status code: (200) JSON response

DownloadFile(string?)

GET /rr_download?name={filename} Download the specified file.

[HttpGet("rr_download")]
public Task<IActionResult> DownloadFile(string? name)

Parameters

name string

File to download

Returns

Task<IActionResult>

HTTP status code: (200) File content (404) File not found

GetFileInfo(string?)

GET /rr_fileinfo?name={filename} Parse a given G-code file and return information about this job file as a JSON object. If name is omitted, info about the file being printed is returned.

[HttpGet("rr_fileinfo")]
public Task<IActionResult> GetFileInfo(string? name)

Parameters

name string

Optional G-code file to analyze

Returns

Task<IActionResult>

HTTP status code: (200) JSON response

GetFileList(string?, int, int)

GET /rr_filelist?dir={directory}&first={first} Retrieve file list

[HttpGet("rr_filelist")]
public Task<IActionResult> GetFileList(string? dir, int first = 0, int max = -1)

Parameters

dir string

Directory to list

first int

First file to list or -1 if unknown

max int

Maximum number of files to list or -1 if unset

Returns

Task<IActionResult>

HTTP status code: (200) JSON response

GetFiles(string?, int, int, int)

GET /rr_files?dir={directory}&first={first}&flagDirs={flagDirs} Retrieve files list

[HttpGet("rr_files")]
public Task<IActionResult> GetFiles(string? dir, int first = 0, int flagDirs = 0, int max = -1)

Parameters

dir string

Directory to list

first int

First file to list (defaults to 0)

flagDirs int

Whether directories should be flagged using an asterisk prefix

max int

Maximum number of files to list or -1 if unset

Returns

Task<IActionResult>

HTTP status code: (200) JSON response

GetModel(string?, string?)

GET /rr_model?key={key}&flags={flags} Retrieve object model information

[HttpGet("rr_model")]
public Task<IActionResult> GetModel(string? key = "", string? flags = "")

Parameters

key string
flags string

Returns

Task<IActionResult>

HTTP status code: (200) JSON response (503) Service Unavailable

GetThumbnail(string?, long)

GET /rr_thumbnail?name={filename}&offset={offset} Get the thumbnail from a given filename

[HttpGet("rr_thumbnail")]
public Task<IActionResult> GetThumbnail(string? name, long offset)

Parameters

name string

G-code file to read thumbnails from

offset long

Start offset of the thumbnail query

Returns

Task<IActionResult>

HTTP status code: (200) JSON response

MoveFileOrDirectory(string?, string?, string?)

Move a file or directory from a to b

[Authorize(Policy = "readWrite")]
[HttpGet("rr_move")]
public Task<IActionResult> MoveFileOrDirectory(string? old, string? @new, string? deleteexisting = "no")

Parameters

old string

Source path

new string

Destination path

deleteexisting string

Delete existing file (optional, default "no")

Returns

Task<IActionResult>

HTTP status code: (200) JSON response

Reply(ISessionStorage)

GET /rr_reply Retrieve the last G-code reply. Messages are only cached per emulated sessions, so they are not cached before an emulated client actually connects.

[HttpGet("rr_reply")]
public IActionResult Reply(ISessionStorage sessionStorage)

Parameters

sessionStorage ISessionStorage

Returns

IActionResult

Last G-code reply

UploadFile(string?, string?, string?, ISessionStorage)

POST /rr_upload?name={filename} Upload a file from the HTTP body and create the subdirectories if necessary

[Authorize(Policy = "readWrite")]
[DisableRequestSizeLimit]
[HttpPost("rr_upload")]
public Task<IActionResult> UploadFile(string? name, string? time, string? crc32, ISessionStorage sessionStorage)

Parameters

name string

Destination of the file to upload

time string

Last modified time of the file

crc32 string

CRC32 checksum of the file

sessionStorage ISessionStorage

Session storage singleton

Returns

Task<IActionResult>

HTTP status code: (200) JSON response

UploadResult()

GET /rr_upload Get the last file upload result.

[HttpGet("rr_upload")]
public IActionResult UploadResult()

Returns

IActionResult

HTTP status code: (200) Error code result