View Source PrusaLink.Api (PrusaLink v0.2.0)

Endpoint implementation according to the openapi spec from Prusa: https://github.com/prusa3d/Prusa-Link-Web/blob/master/spec/openapi.yaml

Summary

Functions

Retuns a file listing for the given storage and path. To find out which storage options are connected to the printer see PrusaLink.Api.storage/1

Returns information about the current printing job if one is running. Otherwise it returns an emtpy list.

Pauses the execution of a currently running job. Can be resumed later.

Resumes a job that was paused before.

Stops a currently running job. The job can not be resumed.

Starts a print job with the given file.

Retrieves current status from the printer.

Returns storage information.

Upload a file to the given printer storage. The given path should include the target filename of the file on the printer and not just the folder.

Functions

Link to this function

files(printer, storage, path)

View Source
@spec files(
  %PrusaLink.Printer{
    api_version: term(),
    capabilities: term(),
    client: term(),
    mmu: term(),
    name: term(),
    nozzle: term(),
    serial: term()
  },
  storage :: binary(),
  path :: binary()
) ::
  {:ok, any()}
  | {:error,
     :not_found
     | :timeout
     | :unauthorized
     | {:error, any()}
     | {:ok, Tesla.Env.t()}}

Retuns a file listing for the given storage and path. To find out which storage options are connected to the printer see PrusaLink.Api.storage/1

Link to this function

info(client, api_version)

View Source
@spec job(%PrusaLink.Printer{
  api_version: term(),
  capabilities: term(),
  client: term(),
  mmu: term(),
  name: term(),
  nozzle: term(),
  serial: term()
}) ::
  {:ok, any()}
  | {:error,
     :not_found
     | :timeout
     | :unauthorized
     | {:error, any()}
     | {:ok, Tesla.Env.t()}}

Returns information about the current printing job if one is running. Otherwise it returns an emtpy list.

Link to this function

job_pause(printer, job_id)

View Source
@spec job_pause(
  %PrusaLink.Printer{
    api_version: term(),
    capabilities: term(),
    client: term(),
    mmu: term(),
    name: term(),
    nozzle: term(),
    serial: term()
  },
  job_id :: integer()
) ::
  {:ok, any()}
  | {:error,
     :not_found
     | :timeout
     | :unauthorized
     | {:error, any()}
     | {:ok, Tesla.Env.t()}}

Pauses the execution of a currently running job. Can be resumed later.

Link to this function

job_resume(printer, job_id)

View Source
@spec job_resume(
  %PrusaLink.Printer{
    api_version: term(),
    capabilities: term(),
    client: term(),
    mmu: term(),
    name: term(),
    nozzle: term(),
    serial: term()
  },
  job_id :: integer()
) ::
  {:ok, any()}
  | {:error,
     :not_found
     | :timeout
     | :unauthorized
     | {:error, any()}
     | {:ok, Tesla.Env.t()}}

Resumes a job that was paused before.

Link to this function

job_stop(printer, job_id)

View Source
@spec job_stop(
  %PrusaLink.Printer{
    api_version: term(),
    capabilities: term(),
    client: term(),
    mmu: term(),
    name: term(),
    nozzle: term(),
    serial: term()
  },
  job_id :: integer()
) ::
  {:ok, any()}
  | {:error,
     :not_found
     | :timeout
     | :unauthorized
     | {:error, any()}
     | {:ok, Tesla.Env.t()}}

Stops a currently running job. The job can not be resumed.

Link to this function

print(printer, storage, path)

View Source
@spec print(
  %PrusaLink.Printer{
    api_version: term(),
    capabilities: term(),
    client: term(),
    mmu: term(),
    name: term(),
    nozzle: term(),
    serial: term()
  },
  storage :: binary(),
  path :: binary()
) ::
  {:ok, any()}
  | {:error,
     :not_found
     | :timeout
     | :unauthorized
     | {:error, any()}
     | {:ok, Tesla.Env.t()}}

Starts a print job with the given file.

Examples

iex> PrusaLink.Api.print(printer, "usb", "/model.bgcode")
{:ok, []}
@spec status(%PrusaLink.Printer{
  api_version: term(),
  capabilities: term(),
  client: term(),
  mmu: term(),
  name: term(),
  nozzle: term(),
  serial: term()
}) ::
  {:ok, any()}
  | {:error,
     :not_found
     | :timeout
     | :unauthorized
     | {:error, any()}
     | {:ok, Tesla.Env.t()}}

Retrieves current status from the printer.

Examples

iex> PrusaLink.status(printer)
{:ok, %{
  job: %{
    id: 297,
    progress: 91.00,
    time_remaining: 600,
    time_printing: 7718
  },
  storage: %{
    path: "/usb/",
    name: "usb",
    read_only: false
  },
  printer: %{
    state: "PRINTING",
    temp_bed: 60.0,
    target_bed: 60.0,
    temp_nozzle: 209.9,
    target_nozzle: 210.0,
    axis_z: 2.4,
    flow: 100,
    speed: 100,
    fan_hotend: 3099,
    fan_print: 5964
  }
}}
@spec storage(%PrusaLink.Printer{
  api_version: term(),
  capabilities: term(),
  client: term(),
  mmu: term(),
  name: term(),
  nozzle: term(),
  serial: term()
}) ::
  {:ok, any()}
  | {:error,
     :not_found
     | :timeout
     | :unauthorized
     | {:error, any()}
     | {:ok, Tesla.Env.t()}}

Returns storage information.

Link to this function

upload(printer, storage, path, content)

View Source (since 0.1.1)
@spec upload(
  %PrusaLink.Printer{
    api_version: term(),
    capabilities: term(),
    client: term(),
    mmu: term(),
    name: term(),
    nozzle: term(),
    serial: term()
  },
  storage :: binary(),
  path :: binary(),
  content :: any()
) ::
  {:ok, any()}
  | {:error,
     :not_found
     | :timeout
     | :unauthorized
     | {:error, any()}
     | {:ok, Tesla.Env.t()}}

Upload a file to the given printer storage. The given path should include the target filename of the file on the printer and not just the folder.

NOTE: Does not override existing file and does not start printing automatically after upload.

Examples

iex> PrusaLink.Api.upload(printer, "usb", "/model.bgcode", file_content)
{:ok, []}