Tom Butcher 9f927b1ef5
Some checks failed
farmcontrol/farmcontrol-server/pipeline/head There was a failure building this commit
Enhance build process and server version management
Refactor build-linux-bundle.mjs to include package version and build number from environment variables and package.json. Update headless.js to streamline initialization and improve error handling. Introduce serverVersion.js to centralize version information retrieval, replacing redundant code in localserver.js. Enhance logging in index.js to display build number and version more clearly.
2026-07-26 23:27:08 +01:00
2025-12-28 21:46:58 +00:00
2025-12-28 21:46:58 +00:00
2025-04-13 18:31:40 +00:00
2025-12-29 02:36:55 +00:00

Farm Control Server

Build Status

A Node.js application that bridges communication between external websocket clients and a Moonraker-controlled 3D printer.

Features

  • Connects to Moonraker API via websocket
  • Provides a websocket server for external clients
  • Relays JSON-RPC commands between clients and the printer
  • Broadcasts printer status updates to all connected clients
  • Handles reconnection if the Moonraker connection is lost

Installation

  1. Clone this repository
  2. Install dependencies:
    npm install
    
  3. Edit the config.json file to match your Moonraker setup
  4. Start the server:
    npm start
    

Configuration

The config.json file contains the following options:

{
  "moonraker": {
    "host": "localhost",
    "port": 7125,
    "protocol": "ws",
    "apiKey": null,
    "identity": {
      "name": "printer-bridge",
      "version": "0.1.0",
      "type": "external"
    }
  },
  "server": {
    "port": 8080
  }
}
  • moonraker.host: The hostname or IP address of your Moonraker instance
  • moonraker.port: The port number of your Moonraker instance
  • moonraker.protocol: The protocol to use (ws or wss)
  • moonraker.apiKey: Your Moonraker API key (if required)
  • server.port: The port number for the websocket server

Usage

Connect to the websocket server at ws://[host]:[port] and send JSON-RPC formatted messages to control the printer.

Example client-side code:

const ws = new WebSocket('ws://localhost:8080');

ws.onopen = () => {
  console.log('Connected to printer bridge');

  // Send a command to get printer info
  ws.send(JSON.stringify({
    jsonrpc: "2.0",
    method: "printer.info",
    id: 1
  }));
};

ws.onmessage = (event) => {
  const message = JSON.parse(event.data);
  console.log('Received:', message);
};

License

MIT

Description
An app for Farmcontrol that bridges communication between Moonraker-controlled 3D printers and websockets.
Readme 5 MiB
Languages
JavaScript 93.9%
PowerShell 2.2%
NSIS 1.3%
CSS 1.1%
TypeScript 0.7%
Other 0.8%