@usarral/century-link-ts 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +171 -0
- package/dist/CenturyLink.d.ts +53 -0
- package/dist/CenturyLink.d.ts.map +1 -0
- package/dist/CenturyLink.js +103 -0
- package/dist/CenturyLink.js.map +1 -0
- package/dist/application/result/ElegooError.d.ts +7 -0
- package/dist/application/result/ElegooError.d.ts.map +1 -0
- package/dist/application/result/ElegooError.js +11 -0
- package/dist/application/result/ElegooError.js.map +1 -0
- package/dist/application/result/Result.d.ts +12 -0
- package/dist/application/result/Result.d.ts.map +1 -0
- package/dist/application/result/Result.js +12 -0
- package/dist/application/result/Result.js.map +1 -0
- package/dist/application/result/Result.test.d.ts +2 -0
- package/dist/application/result/Result.test.d.ts.map +1 -0
- package/dist/application/result/Result.test.js +46 -0
- package/dist/application/result/Result.test.js.map +1 -0
- package/dist/application/use-cases/ConnectPrinterUseCase.d.ts +9 -0
- package/dist/application/use-cases/ConnectPrinterUseCase.d.ts.map +1 -0
- package/dist/application/use-cases/ConnectPrinterUseCase.js +10 -0
- package/dist/application/use-cases/ConnectPrinterUseCase.js.map +1 -0
- package/dist/application/use-cases/DiscoverPrintersUseCase.d.ts +8 -0
- package/dist/application/use-cases/DiscoverPrintersUseCase.d.ts.map +1 -0
- package/dist/application/use-cases/DiscoverPrintersUseCase.js +36 -0
- package/dist/application/use-cases/DiscoverPrintersUseCase.js.map +1 -0
- package/dist/application/use-cases/GetFileListUseCase.d.ts +9 -0
- package/dist/application/use-cases/GetFileListUseCase.d.ts.map +1 -0
- package/dist/application/use-cases/GetFileListUseCase.js +10 -0
- package/dist/application/use-cases/GetFileListUseCase.js.map +1 -0
- package/dist/application/use-cases/GetPrinterStatusUseCase.d.ts +9 -0
- package/dist/application/use-cases/GetPrinterStatusUseCase.d.ts.map +1 -0
- package/dist/application/use-cases/GetPrinterStatusUseCase.js +10 -0
- package/dist/application/use-cases/GetPrinterStatusUseCase.js.map +1 -0
- package/dist/application/use-cases/PausePrintUseCase.d.ts +8 -0
- package/dist/application/use-cases/PausePrintUseCase.d.ts.map +1 -0
- package/dist/application/use-cases/PausePrintUseCase.js +10 -0
- package/dist/application/use-cases/PausePrintUseCase.js.map +1 -0
- package/dist/application/use-cases/ResumePrintUseCase.d.ts +8 -0
- package/dist/application/use-cases/ResumePrintUseCase.d.ts.map +1 -0
- package/dist/application/use-cases/ResumePrintUseCase.js +10 -0
- package/dist/application/use-cases/ResumePrintUseCase.js.map +1 -0
- package/dist/application/use-cases/StartPrintUseCase.d.ts +8 -0
- package/dist/application/use-cases/StartPrintUseCase.d.ts.map +1 -0
- package/dist/application/use-cases/StartPrintUseCase.js +10 -0
- package/dist/application/use-cases/StartPrintUseCase.js.map +1 -0
- package/dist/application/use-cases/StopPrintUseCase.d.ts +8 -0
- package/dist/application/use-cases/StopPrintUseCase.d.ts.map +1 -0
- package/dist/application/use-cases/StopPrintUseCase.js +10 -0
- package/dist/application/use-cases/StopPrintUseCase.js.map +1 -0
- package/dist/application/use-cases/UploadFileUseCase.d.ts +8 -0
- package/dist/application/use-cases/UploadFileUseCase.d.ts.map +1 -0
- package/dist/application/use-cases/UploadFileUseCase.js +10 -0
- package/dist/application/use-cases/UploadFileUseCase.js.map +1 -0
- package/dist/domain/entities/DiscoveredPrinter.d.ts +14 -0
- package/dist/domain/entities/DiscoveredPrinter.d.ts.map +1 -0
- package/dist/domain/entities/DiscoveredPrinter.js +2 -0
- package/dist/domain/entities/DiscoveredPrinter.js.map +1 -0
- package/dist/domain/entities/FileInfo.d.ts +26 -0
- package/dist/domain/entities/FileInfo.d.ts.map +1 -0
- package/dist/domain/entities/FileInfo.js +2 -0
- package/dist/domain/entities/FileInfo.js.map +1 -0
- package/dist/domain/entities/PrintTask.d.ts +17 -0
- package/dist/domain/entities/PrintTask.d.ts.map +1 -0
- package/dist/domain/entities/PrintTask.js +2 -0
- package/dist/domain/entities/PrintTask.js.map +1 -0
- package/dist/domain/entities/PrinterAttributes.d.ts +44 -0
- package/dist/domain/entities/PrinterAttributes.d.ts.map +1 -0
- package/dist/domain/entities/PrinterAttributes.js +2 -0
- package/dist/domain/entities/PrinterAttributes.js.map +1 -0
- package/dist/domain/entities/PrinterInfo.d.ts +16 -0
- package/dist/domain/entities/PrinterInfo.d.ts.map +1 -0
- package/dist/domain/entities/PrinterInfo.js +2 -0
- package/dist/domain/entities/PrinterInfo.js.map +1 -0
- package/dist/domain/entities/PrinterStatus.d.ts +86 -0
- package/dist/domain/entities/PrinterStatus.d.ts.map +1 -0
- package/dist/domain/entities/PrinterStatus.js +2 -0
- package/dist/domain/entities/PrinterStatus.js.map +1 -0
- package/dist/domain/events/PrinterAttributesEvent.d.ts +7 -0
- package/dist/domain/events/PrinterAttributesEvent.d.ts.map +1 -0
- package/dist/domain/events/PrinterAttributesEvent.js +2 -0
- package/dist/domain/events/PrinterAttributesEvent.js.map +1 -0
- package/dist/domain/events/PrinterConnectionEvent.d.ts +6 -0
- package/dist/domain/events/PrinterConnectionEvent.d.ts.map +1 -0
- package/dist/domain/events/PrinterConnectionEvent.js +2 -0
- package/dist/domain/events/PrinterConnectionEvent.js.map +1 -0
- package/dist/domain/events/PrinterStatusEvent.d.ts +7 -0
- package/dist/domain/events/PrinterStatusEvent.d.ts.map +1 -0
- package/dist/domain/events/PrinterStatusEvent.js +2 -0
- package/dist/domain/events/PrinterStatusEvent.js.map +1 -0
- package/dist/domain/ports/DiscoveryAdapter.d.ts +10 -0
- package/dist/domain/ports/DiscoveryAdapter.d.ts.map +1 -0
- package/dist/domain/ports/DiscoveryAdapter.js +2 -0
- package/dist/domain/ports/DiscoveryAdapter.js.map +1 -0
- package/dist/domain/ports/EventBus.d.ts +8 -0
- package/dist/domain/ports/EventBus.d.ts.map +1 -0
- package/dist/domain/ports/EventBus.js +2 -0
- package/dist/domain/ports/EventBus.js.map +1 -0
- package/dist/domain/ports/FileAdapter.d.ts +26 -0
- package/dist/domain/ports/FileAdapter.d.ts.map +1 -0
- package/dist/domain/ports/FileAdapter.js +2 -0
- package/dist/domain/ports/FileAdapter.js.map +1 -0
- package/dist/domain/ports/PrinterAdapter.d.ts +74 -0
- package/dist/domain/ports/PrinterAdapter.d.ts.map +1 -0
- package/dist/domain/ports/PrinterAdapter.js +2 -0
- package/dist/domain/ports/PrinterAdapter.js.map +1 -0
- package/dist/domain/types/ErrorCode.d.ts +43 -0
- package/dist/domain/types/ErrorCode.d.ts.map +1 -0
- package/dist/domain/types/ErrorCode.js +49 -0
- package/dist/domain/types/ErrorCode.js.map +1 -0
- package/dist/domain/types/PrinterState.d.ts +24 -0
- package/dist/domain/types/PrinterState.d.ts.map +1 -0
- package/dist/domain/types/PrinterState.js +25 -0
- package/dist/domain/types/PrinterState.js.map +1 -0
- package/dist/domain/types/PrinterSubState.d.ts +59 -0
- package/dist/domain/types/PrinterSubState.d.ts.map +1 -0
- package/dist/domain/types/PrinterSubState.js +73 -0
- package/dist/domain/types/PrinterSubState.js.map +1 -0
- package/dist/domain/types/PrinterType.d.ts +8 -0
- package/dist/domain/types/PrinterType.d.ts.map +1 -0
- package/dist/domain/types/PrinterType.js +9 -0
- package/dist/domain/types/PrinterType.js.map +1 -0
- package/dist/domain/value-objects/PrinterId.d.ts +7 -0
- package/dist/domain/value-objects/PrinterId.d.ts.map +1 -0
- package/dist/domain/value-objects/PrinterId.js +6 -0
- package/dist/domain/value-objects/PrinterId.js.map +1 -0
- package/dist/domain/value-objects/Progress.d.ts +9 -0
- package/dist/domain/value-objects/Progress.d.ts.map +1 -0
- package/dist/domain/value-objects/Progress.js +4 -0
- package/dist/domain/value-objects/Progress.js.map +1 -0
- package/dist/domain/value-objects/Temperature.d.ts +8 -0
- package/dist/domain/value-objects/Temperature.d.ts.map +1 -0
- package/dist/domain/value-objects/Temperature.js +4 -0
- package/dist/domain/value-objects/Temperature.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/adapters/cc-v1/CcV1DiscoveryAdapter.d.ts +6 -0
- package/dist/infrastructure/adapters/cc-v1/CcV1DiscoveryAdapter.d.ts.map +1 -0
- package/dist/infrastructure/adapters/cc-v1/CcV1DiscoveryAdapter.js +39 -0
- package/dist/infrastructure/adapters/cc-v1/CcV1DiscoveryAdapter.js.map +1 -0
- package/dist/infrastructure/adapters/cc-v1/CcV1FileAdapter.d.ts +16 -0
- package/dist/infrastructure/adapters/cc-v1/CcV1FileAdapter.d.ts.map +1 -0
- package/dist/infrastructure/adapters/cc-v1/CcV1FileAdapter.js +87 -0
- package/dist/infrastructure/adapters/cc-v1/CcV1FileAdapter.js.map +1 -0
- package/dist/infrastructure/adapters/cc-v1/CcV1PrinterAdapter.d.ts +47 -0
- package/dist/infrastructure/adapters/cc-v1/CcV1PrinterAdapter.d.ts.map +1 -0
- package/dist/infrastructure/adapters/cc-v1/CcV1PrinterAdapter.js +332 -0
- package/dist/infrastructure/adapters/cc-v1/CcV1PrinterAdapter.js.map +1 -0
- package/dist/infrastructure/adapters/cc-v1/CcV1StatusMapper.d.ts +36 -0
- package/dist/infrastructure/adapters/cc-v1/CcV1StatusMapper.d.ts.map +1 -0
- package/dist/infrastructure/adapters/cc-v1/CcV1StatusMapper.js +59 -0
- package/dist/infrastructure/adapters/cc-v1/CcV1StatusMapper.js.map +1 -0
- package/dist/infrastructure/adapters/cc-v2/CcV2DiscoveryAdapter.d.ts +6 -0
- package/dist/infrastructure/adapters/cc-v2/CcV2DiscoveryAdapter.d.ts.map +1 -0
- package/dist/infrastructure/adapters/cc-v2/CcV2DiscoveryAdapter.js +41 -0
- package/dist/infrastructure/adapters/cc-v2/CcV2DiscoveryAdapter.js.map +1 -0
- package/dist/infrastructure/adapters/cc-v2/CcV2FileAdapter.d.ts +16 -0
- package/dist/infrastructure/adapters/cc-v2/CcV2FileAdapter.d.ts.map +1 -0
- package/dist/infrastructure/adapters/cc-v2/CcV2FileAdapter.js +117 -0
- package/dist/infrastructure/adapters/cc-v2/CcV2FileAdapter.js.map +1 -0
- package/dist/infrastructure/adapters/cc-v2/CcV2PrinterAdapter.d.ts +50 -0
- package/dist/infrastructure/adapters/cc-v2/CcV2PrinterAdapter.d.ts.map +1 -0
- package/dist/infrastructure/adapters/cc-v2/CcV2PrinterAdapter.js +410 -0
- package/dist/infrastructure/adapters/cc-v2/CcV2PrinterAdapter.js.map +1 -0
- package/dist/infrastructure/adapters/cc-v2/CcV2StatusMapper.d.ts +81 -0
- package/dist/infrastructure/adapters/cc-v2/CcV2StatusMapper.d.ts.map +1 -0
- package/dist/infrastructure/adapters/cc-v2/CcV2StatusMapper.js +116 -0
- package/dist/infrastructure/adapters/cc-v2/CcV2StatusMapper.js.map +1 -0
- package/dist/infrastructure/adapters/cc-v2/CcV2StatusMapper.test.d.ts +2 -0
- package/dist/infrastructure/adapters/cc-v2/CcV2StatusMapper.test.d.ts.map +1 -0
- package/dist/infrastructure/adapters/cc-v2/CcV2StatusMapper.test.js +59 -0
- package/dist/infrastructure/adapters/cc-v2/CcV2StatusMapper.test.js.map +1 -0
- package/dist/infrastructure/adapters/moonraker/MoonrakerFileAdapter.d.ts +16 -0
- package/dist/infrastructure/adapters/moonraker/MoonrakerFileAdapter.d.ts.map +1 -0
- package/dist/infrastructure/adapters/moonraker/MoonrakerFileAdapter.js +137 -0
- package/dist/infrastructure/adapters/moonraker/MoonrakerFileAdapter.js.map +1 -0
- package/dist/infrastructure/adapters/moonraker/MoonrakerPrinterAdapter.d.ts +52 -0
- package/dist/infrastructure/adapters/moonraker/MoonrakerPrinterAdapter.d.ts.map +1 -0
- package/dist/infrastructure/adapters/moonraker/MoonrakerPrinterAdapter.js +303 -0
- package/dist/infrastructure/adapters/moonraker/MoonrakerPrinterAdapter.js.map +1 -0
- package/dist/infrastructure/adapters/moonraker/MoonrakerStatusMapper.d.ts +37 -0
- package/dist/infrastructure/adapters/moonraker/MoonrakerStatusMapper.d.ts.map +1 -0
- package/dist/infrastructure/adapters/moonraker/MoonrakerStatusMapper.js +84 -0
- package/dist/infrastructure/adapters/moonraker/MoonrakerStatusMapper.js.map +1 -0
- package/dist/infrastructure/factory/PrinterAdapterFactory.d.ts +12 -0
- package/dist/infrastructure/factory/PrinterAdapterFactory.d.ts.map +1 -0
- package/dist/infrastructure/factory/PrinterAdapterFactory.js +42 -0
- package/dist/infrastructure/factory/PrinterAdapterFactory.js.map +1 -0
- package/dist/infrastructure/transport/Transport.d.ts +19 -0
- package/dist/infrastructure/transport/Transport.d.ts.map +1 -0
- package/dist/infrastructure/transport/Transport.js +2 -0
- package/dist/infrastructure/transport/Transport.js.map +1 -0
- package/dist/infrastructure/transport/http/HttpClient.d.ts +23 -0
- package/dist/infrastructure/transport/http/HttpClient.d.ts.map +1 -0
- package/dist/infrastructure/transport/http/HttpClient.js +73 -0
- package/dist/infrastructure/transport/http/HttpClient.js.map +1 -0
- package/dist/infrastructure/transport/mqtt/CcV2Codec.d.ts +46 -0
- package/dist/infrastructure/transport/mqtt/CcV2Codec.d.ts.map +1 -0
- package/dist/infrastructure/transport/mqtt/CcV2Codec.js +41 -0
- package/dist/infrastructure/transport/mqtt/CcV2Codec.js.map +1 -0
- package/dist/infrastructure/transport/mqtt/CcV2Codec.test.d.ts +2 -0
- package/dist/infrastructure/transport/mqtt/CcV2Codec.test.d.ts.map +1 -0
- package/dist/infrastructure/transport/mqtt/CcV2Codec.test.js +48 -0
- package/dist/infrastructure/transport/mqtt/CcV2Codec.test.js.map +1 -0
- package/dist/infrastructure/transport/mqtt/MqttTransport.d.ts +26 -0
- package/dist/infrastructure/transport/mqtt/MqttTransport.d.ts.map +1 -0
- package/dist/infrastructure/transport/mqtt/MqttTransport.js +188 -0
- package/dist/infrastructure/transport/mqtt/MqttTransport.js.map +1 -0
- package/dist/infrastructure/transport/udp/UdpSocket.d.ts +13 -0
- package/dist/infrastructure/transport/udp/UdpSocket.d.ts.map +1 -0
- package/dist/infrastructure/transport/udp/UdpSocket.js +37 -0
- package/dist/infrastructure/transport/udp/UdpSocket.js.map +1 -0
- package/dist/infrastructure/transport/websocket/CcV1Codec.d.ts +33 -0
- package/dist/infrastructure/transport/websocket/CcV1Codec.d.ts.map +1 -0
- package/dist/infrastructure/transport/websocket/CcV1Codec.js +51 -0
- package/dist/infrastructure/transport/websocket/CcV1Codec.js.map +1 -0
- package/dist/infrastructure/transport/websocket/CcV1Codec.test.d.ts +2 -0
- package/dist/infrastructure/transport/websocket/CcV1Codec.test.d.ts.map +1 -0
- package/dist/infrastructure/transport/websocket/CcV1Codec.test.js +79 -0
- package/dist/infrastructure/transport/websocket/CcV1Codec.test.js.map +1 -0
- package/dist/infrastructure/transport/websocket/WebSocketTransport.d.ts +13 -0
- package/dist/infrastructure/transport/websocket/WebSocketTransport.d.ts.map +1 -0
- package/dist/infrastructure/transport/websocket/WebSocketTransport.js +71 -0
- package/dist/infrastructure/transport/websocket/WebSocketTransport.js.map +1 -0
- package/docs/cc2-protocol.md +244 -0
- package/package.json +59 -0
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
# Elegoo CC2 LAN Protocol
|
|
2
|
+
|
|
3
|
+
Protocol reference reverse-engineered from the Elegoo Slicer v1.5.0.7 web UI (`elegoolink/web/lan_service_web/index.html`).
|
|
4
|
+
|
|
5
|
+
## Transport
|
|
6
|
+
|
|
7
|
+
All communication uses **MQTT over TCP** on port **1883**.
|
|
8
|
+
|
|
9
|
+
### Credentials
|
|
10
|
+
|
|
11
|
+
| Field | Value |
|
|
12
|
+
|----------|--------------------|
|
|
13
|
+
| Username | `elegoo` |
|
|
14
|
+
| Password | printer access code (shown in printer settings) |
|
|
15
|
+
|
|
16
|
+
### Client ID format
|
|
17
|
+
|
|
18
|
+
Client IDs follow this pattern, matching the slicer's own `I7e()` generator:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
"0" + "cli" + last5hex(Date.now()) + 3hex(Math.random()) → slice(0, 10)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Example output: `0cli29ccdd`, `0cli315bfd`.
|
|
25
|
+
|
|
26
|
+
The format is always 10 characters: `0cli` prefix + 6 hex digits.
|
|
27
|
+
|
|
28
|
+
> **Why this matters:** The printer firmware uses the MQTT client ID embedded in the topic path to route responses. Only a client that has completed the registration handshake (see below) will receive replies to its requests.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Topic structure
|
|
33
|
+
|
|
34
|
+
| Purpose | Topic pattern | Publisher |
|
|
35
|
+
|--------------------------|-----------------------------------------------------|------------|
|
|
36
|
+
| Registration request | `elegoo/{sn}/api_register` | client |
|
|
37
|
+
| Registration response | `elegoo/{sn}/{clientId}/register_response` | printer |
|
|
38
|
+
| API request | `elegoo/{sn}/{clientId}/api_request` | client |
|
|
39
|
+
| API response | `elegoo/{sn}/{clientId}/api_response` | printer |
|
|
40
|
+
| Status push (unsolicited)| `elegoo/{sn}/api_status` | printer |
|
|
41
|
+
| Heartbeat | `elegoo/{sn}/{clientId}/api_heartbeat` | client |
|
|
42
|
+
|
|
43
|
+
`{sn}` is the printer serial number (e.g. `F01SZJNY4A1FRZS`).
|
|
44
|
+
`{clientId}` is the 10-character client ID generated above.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Connection flow
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
Client Printer MQTT Broker
|
|
52
|
+
│ │
|
|
53
|
+
│── MQTT CONNECT (clientId, user, pass) ──────>│
|
|
54
|
+
│<─ CONNACK ──────────────────────────────────│
|
|
55
|
+
│ │
|
|
56
|
+
│── SUBSCRIBE elegoo/{sn}/api_status ─────────>│
|
|
57
|
+
│── SUBSCRIBE elegoo/{sn}/{id}/api_response ──>│
|
|
58
|
+
│── SUBSCRIBE elegoo/{sn}/{id}/register_response>│
|
|
59
|
+
│<─ SUBACK ───────────────────────────────────│
|
|
60
|
+
│ │
|
|
61
|
+
│── PUBLISH elegoo/{sn}/api_register ─────────>│ { request_id: clientId, client_id: clientId }
|
|
62
|
+
│<─ PUBLISH elegoo/{sn}/{id}/register_response─│ { client_id: clientId, error: "ok" }
|
|
63
|
+
│ │
|
|
64
|
+
│ ← registered, ready to send requests → │
|
|
65
|
+
│ │
|
|
66
|
+
│── PUBLISH elegoo/{sn}/{id}/api_request ─────>│ { id: 1, method: 1001, params: {} }
|
|
67
|
+
│<─ PUBLISH elegoo/{sn}/{id}/api_response ────│ { id: 1, method: 1001, result: { ... } }
|
|
68
|
+
│ │
|
|
69
|
+
│ (printer pushes status independently) │
|
|
70
|
+
│<─ PUBLISH elegoo/{sn}/api_status ───────────│ { id: N, method: 6000, result: { ... } }
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
> **Important:** The registration handshake is required. Without it the printer ignores all requests from that client ID, regardless of topic structure or credentials. Multiple clients can register concurrently — registration does not evict existing sessions.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Message formats
|
|
78
|
+
|
|
79
|
+
### Registration request
|
|
80
|
+
|
|
81
|
+
Published to `elegoo/{sn}/api_register`:
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"request_id": "0cli29ccdd",
|
|
86
|
+
"client_id": "0cli29ccdd"
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Both fields carry the same client ID value.
|
|
91
|
+
|
|
92
|
+
### Registration response
|
|
93
|
+
|
|
94
|
+
Received on `elegoo/{sn}/{clientId}/register_response`:
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
{ "client_id": "0cli29ccdd", "error": "ok" }
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
`error: "ok"` means success. Any other value indicates failure.
|
|
101
|
+
|
|
102
|
+
### API request
|
|
103
|
+
|
|
104
|
+
Published to `elegoo/{sn}/{clientId}/api_request`:
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{ "id": 1, "method": 1001, "params": {} }
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
`id` is a monotonically increasing integer used to match responses. `method` is one of the method codes below.
|
|
111
|
+
|
|
112
|
+
### API response
|
|
113
|
+
|
|
114
|
+
Received on `elegoo/{sn}/{clientId}/api_response`:
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{ "id": 1, "method": 1001, "result": { ... } }
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
The `id` field echoes the request. Check `result.error_code === 0` for success.
|
|
121
|
+
|
|
122
|
+
### Status push (unsolicited)
|
|
123
|
+
|
|
124
|
+
Received on `elegoo/{sn}/api_status`. The printer emits these continuously:
|
|
125
|
+
|
|
126
|
+
```json
|
|
127
|
+
{ "id": 5700, "method": 6000, "result": { "extruder": { "temperature": 27 }, ... } }
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Pushes are **incremental** — only changed fields are included. Build a full state by merging successive pushes.
|
|
131
|
+
|
|
132
|
+
### Heartbeat
|
|
133
|
+
|
|
134
|
+
Published by the client to `elegoo/{sn}/{clientId}/api_heartbeat` every ~30 s to keep the session alive:
|
|
135
|
+
|
|
136
|
+
```json
|
|
137
|
+
{ "id": 0 }
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Method codes
|
|
143
|
+
|
|
144
|
+
### Request → Response
|
|
145
|
+
|
|
146
|
+
| Code | Name | Description |
|
|
147
|
+
|------|-----------------------|--------------------------------------|
|
|
148
|
+
| 1001 | `GET_ATTRIBUTES` | Printer model, firmware, hostname |
|
|
149
|
+
| 1002 | `GET_STATUS` | Full printer state snapshot |
|
|
150
|
+
| 1020 | `START_PRINT` | Start a print job |
|
|
151
|
+
| 1021 | `PAUSE_PRINT` | Pause current print |
|
|
152
|
+
| 1022 | `STOP_PRINT` | Stop/cancel current print |
|
|
153
|
+
| 1023 | `RESUME_PRINT` | Resume paused print |
|
|
154
|
+
| 1026 | `HOME_AXES` | Home one or more axes |
|
|
155
|
+
| 1027 | `MOVE_AXES` | Jog axes by a distance |
|
|
156
|
+
| 1028 | `SET_TEMPERATURE` | Set extruder / bed targets |
|
|
157
|
+
| 1030 | `SET_FAN_SPEED` | Set fan speeds |
|
|
158
|
+
| 1031 | `SET_PRINT_SPEED` | Set speed mode (0–3) |
|
|
159
|
+
| 1036 | `GET_PRINT_TASK_LIST` | Paginated job history |
|
|
160
|
+
| 1038 | `DELETE_PRINT_TASKS` | Delete jobs by task ID |
|
|
161
|
+
| 1043 | `UPDATE_NAME` | Change printer hostname |
|
|
162
|
+
| 1044 | `GET_FILE_LIST` | Paginated file listing |
|
|
163
|
+
| 1046 | `GET_FILE_DETAIL` | Metadata for a single file |
|
|
164
|
+
| 1057 | `DOWNLOAD_FILE` | Trigger printer to pull a file by URL|
|
|
165
|
+
| 1058 | `CANCEL_DOWNLOAD` | Cancel an in-progress download |
|
|
166
|
+
| 2004 | `SET_AUTO_REFILL` | Enable/disable auto filament refill |
|
|
167
|
+
| 2005 | `GET_CANVAS_STATUS` | Multi-filament canvas/tray state |
|
|
168
|
+
| 7000 | `DISCOVERY` | LAN discovery probe |
|
|
169
|
+
|
|
170
|
+
### Printer → Client (push / unsolicited)
|
|
171
|
+
|
|
172
|
+
| Code | Name | Description |
|
|
173
|
+
|------|-------------------|---------------------------------------------|
|
|
174
|
+
| 6000 | `ON_STATUS` | Incremental status update (continuous push) |
|
|
175
|
+
| 6008 | `ON_ATTRIBUTES` | Attributes update (pushed after changes) |
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Example: GET_ATTRIBUTES (1001)
|
|
180
|
+
|
|
181
|
+
**Request:**
|
|
182
|
+
```json
|
|
183
|
+
{ "id": 1, "method": 1001, "params": {} }
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**Response:**
|
|
187
|
+
```json
|
|
188
|
+
{
|
|
189
|
+
"id": 1,
|
|
190
|
+
"method": 1001,
|
|
191
|
+
"result": {
|
|
192
|
+
"error_code": 0,
|
|
193
|
+
"hardware_version": "",
|
|
194
|
+
"hostname": "Elegoo Centauri Carbon 2",
|
|
195
|
+
"ip": "10.0.0.251",
|
|
196
|
+
"machine_model": "Centauri Carbon 2",
|
|
197
|
+
"protocol_version": "1.0.0",
|
|
198
|
+
"sn": "F01SZJNY4A1FRZS",
|
|
199
|
+
"software_version": {
|
|
200
|
+
"mcu_version": "00.00.00.00",
|
|
201
|
+
"ota_version": "02.00.02.00",
|
|
202
|
+
"soc_version": ""
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Example: GET_STATUS (1002)
|
|
209
|
+
|
|
210
|
+
**Request:**
|
|
211
|
+
```json
|
|
212
|
+
{ "id": 2, "method": 1002, "params": {} }
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**Response** (abbreviated):
|
|
216
|
+
```json
|
|
217
|
+
{
|
|
218
|
+
"id": 2,
|
|
219
|
+
"method": 1002,
|
|
220
|
+
"result": {
|
|
221
|
+
"error_code": 0,
|
|
222
|
+
"extruder": { "temperature": 27, "target": 0, "filament_detected": 0 },
|
|
223
|
+
"heater_bed": { "temperature": 24, "target": 0 },
|
|
224
|
+
"fans": {
|
|
225
|
+
"fan": { "speed": 0.0 },
|
|
226
|
+
"box_fan": { "speed": 0.0 },
|
|
227
|
+
"aux_fan": { "speed": 0.0 }
|
|
228
|
+
},
|
|
229
|
+
"machine_status": { "status": 1, "progress": 0, "sub_status": 0 },
|
|
230
|
+
"print_status": { "enable": false, "filename": "", "current_layer": 0 },
|
|
231
|
+
"led": { "status": 0 },
|
|
232
|
+
"external_device": { "camera": true, "u_disk": true }
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## Notes
|
|
240
|
+
|
|
241
|
+
- All MQTT publishes use **QoS 1**.
|
|
242
|
+
- The printer sends `api_status` pushes roughly every second with only the fields that changed since the last push.
|
|
243
|
+
- The `GET_CANVAS_STATUS` (2005) result nests canvas/tray data under `result.canvas_info` (not `result.canvas_status` as the field is named in some CC2 firmware versions — validate against actual hardware).
|
|
244
|
+
- The Elegoo Slicer persists the client ID in `sessionStorage` so it survives page reloads without re-registering. In a Node.js context a fresh client ID per connection is fine — re-registration always succeeds.
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@usarral/century-link-ts",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript library for communicating with Elegoo 3D printers over LAN",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"docs",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=18.0.0"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"elegoo",
|
|
25
|
+
"3d-printer",
|
|
26
|
+
"iot",
|
|
27
|
+
"mqtt",
|
|
28
|
+
"websocket"
|
|
29
|
+
],
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/usarral/century-link-ts.git"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://github.com/usarral/century-link-ts#readme",
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/usarral/century-link-ts/issues"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"registry": "https://registry.npmjs.org/",
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"mqtt": "^5.10.4",
|
|
45
|
+
"ws": "^8.18.2"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/node": "^22.15.29",
|
|
49
|
+
"@types/ws": "^8.5.14",
|
|
50
|
+
"typescript": "^5.8.3",
|
|
51
|
+
"vitest": "^4.1.8"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "tsc",
|
|
55
|
+
"typecheck": "tsc --noEmit",
|
|
56
|
+
"test": "vitest run",
|
|
57
|
+
"test:watch": "vitest"
|
|
58
|
+
}
|
|
59
|
+
}
|