View Source PrusaLink.Printer (PrusaLink v0.2.1)

Representation of a Prusa 3D printer and how to connect to it.

Summary

Functions

Create a new printer representation. It tries to connect to two endpoints (version & info) to retrieve meta information.

Connect to the printer to update meta data and specs. Useful if you called PrusaLink.Printer.new/2 before and received a {:not_reachable, printer_struct}, you can pass the printer_struct in and try again.

Retuns the meta information retrieved from the printer when connecting to it the first time.

Functions

Link to this function

new(host_or_ip, password)

View Source
@spec new(host_or_ip :: binary(), password :: binary()) ::
  {:ok,
   %PrusaLink.Printer{
     api_version: integer(),
     capabilities: term(),
     client: Tesla.Client.t(),
     mmu: term(),
     name: term(),
     nozzle: term(),
     serial: term()
   }}
  | {:not_reachable,
     %PrusaLink.Printer{
       api_version: integer(),
       capabilities: term(),
       client: Tesla.Client.t(),
       mmu: term(),
       name: term(),
       nozzle: term(),
       serial: term()
     }}
  | {:error, reason :: any()}

Create a new printer representation. It tries to connect to two endpoints (version & info) to retrieve meta information.

Returns a %PrusaLink.Printer{} struct including the information to connect to the printer as well as some meta information. If the printer can not be reached it returns a tuple with {:unreachable, %Printer{}}. The printer struct can still be used to connect to the printer later assuming the giving information is correct.

Link to this function

refresh(printer)

View Source (since 0.1.3)
@spec refresh(%PrusaLink.Printer{
  api_version: term(),
  capabilities: term(),
  client: term(),
  mmu: term(),
  name: term(),
  nozzle: term(),
  serial: term()
}) ::
  {:ok,
   %PrusaLink.Printer{
     api_version: integer(),
     capabilities: term(),
     client: Tesla.Client.t(),
     mmu: term(),
     name: term(),
     nozzle: term(),
     serial: term()
   }}
  | {:not_reachable,
     %PrusaLink.Printer{
       api_version: integer(),
       capabilities: term(),
       client: Tesla.Client.t(),
       mmu: term(),
       name: term(),
       nozzle: term(),
       serial: term()
     }}
  | {:error, reason :: any()}

Connect to the printer to update meta data and specs. Useful if you called PrusaLink.Printer.new/2 before and received a {:not_reachable, printer_struct}, you can pass the printer_struct in and try again.

@spec specs(%PrusaLink.Printer{
  api_version: term(),
  capabilities: term(),
  client: term(),
  mmu: term(),
  name: term(),
  nozzle: term(),
  serial: term()
}) :: map()

Retuns the meta information retrieved from the printer when connecting to it the first time.

Examples

iex> PrusaLink.Printer.specs(mk4)
%{
  name: "prusa-mk4",
  serial: "1234567890",
  api_version: 1,
  capabilities: %{"upload-by-put": true},
  nozzle: 0.4,
  mmu: false
}