n8n-nodes-bambulab 0.1.2
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 +273 -0
- package/dist/credentials/BambuLabApi.credentials.d.ts +10 -0
- package/dist/credentials/BambuLabApi.credentials.d.ts.map +1 -0
- package/dist/credentials/BambuLabApi.credentials.js +73 -0
- package/dist/credentials/BambuLabApi.credentials.js.map +1 -0
- package/dist/nodes/BambuLab/BambuLab.node.d.ts +6 -0
- package/dist/nodes/BambuLab/BambuLab.node.d.ts.map +1 -0
- package/dist/nodes/BambuLab/BambuLab.node.js +647 -0
- package/dist/nodes/BambuLab/BambuLab.node.js.map +1 -0
- package/dist/nodes/BambuLab/bambulab.svg +29 -0
- package/dist/nodes/BambuLab/helpers/FtpHelper.d.ts +60 -0
- package/dist/nodes/BambuLab/helpers/FtpHelper.d.ts.map +1 -0
- package/dist/nodes/BambuLab/helpers/FtpHelper.js +238 -0
- package/dist/nodes/BambuLab/helpers/FtpHelper.js.map +1 -0
- package/dist/nodes/BambuLab/helpers/MqttHelper.d.ts +52 -0
- package/dist/nodes/BambuLab/helpers/MqttHelper.d.ts.map +1 -0
- package/dist/nodes/BambuLab/helpers/MqttHelper.js +314 -0
- package/dist/nodes/BambuLab/helpers/MqttHelper.js.map +1 -0
- package/dist/nodes/BambuLab/helpers/commands.d.ts +116 -0
- package/dist/nodes/BambuLab/helpers/commands.d.ts.map +1 -0
- package/dist/nodes/BambuLab/helpers/commands.js +242 -0
- package/dist/nodes/BambuLab/helpers/commands.js.map +1 -0
- package/dist/nodes/BambuLab/helpers/types.d.ts +277 -0
- package/dist/nodes/BambuLab/helpers/types.d.ts.map +1 -0
- package/dist/nodes/BambuLab/helpers/types.js +7 -0
- package/dist/nodes/BambuLab/helpers/types.js.map +1 -0
- package/examples/README.md +140 -0
- package/examples/monitor-print-progress.json +123 -0
- package/examples/upload-and-print.json +108 -0
- package/package.json +72 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60" width="60" height="60">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
4
|
+
<stop offset="0%" style="stop-color:#00D26A;stop-opacity:1" />
|
|
5
|
+
<stop offset="100%" style="stop-color:#00A854;stop-opacity:1" />
|
|
6
|
+
</linearGradient>
|
|
7
|
+
</defs>
|
|
8
|
+
|
|
9
|
+
<!-- Background Circle -->
|
|
10
|
+
<circle cx="30" cy="30" r="28" fill="url(#grad1)"/>
|
|
11
|
+
|
|
12
|
+
<!-- 3D Printer Frame -->
|
|
13
|
+
<rect x="15" y="12" width="30" height="3" fill="#FFFFFF" opacity="0.9"/>
|
|
14
|
+
<rect x="16" y="15" width="2" height="25" fill="#FFFFFF" opacity="0.8"/>
|
|
15
|
+
<rect x="42" y="15" width="2" height="25" fill="#FFFFFF" opacity="0.8"/>
|
|
16
|
+
|
|
17
|
+
<!-- Print Bed -->
|
|
18
|
+
<rect x="17" y="38" width="26" height="2" fill="#FFFFFF" opacity="0.9"/>
|
|
19
|
+
|
|
20
|
+
<!-- Print Head -->
|
|
21
|
+
<rect x="23" y="20" width="14" height="6" fill="#FFFFFF" opacity="0.9" rx="1"/>
|
|
22
|
+
<rect x="28" y="26" width="4" height="8" fill="#FFFFFF" opacity="0.7"/>
|
|
23
|
+
|
|
24
|
+
<!-- Printing Material (small cube being printed) -->
|
|
25
|
+
<rect x="26" y="32" width="8" height="6" fill="#FFFFFF" opacity="0.9"/>
|
|
26
|
+
|
|
27
|
+
<!-- Logo Text -->
|
|
28
|
+
<text x="30" y="52" font-family="Arial, sans-serif" font-size="8" font-weight="bold" fill="#FFFFFF" text-anchor="middle">BL</text>
|
|
29
|
+
</svg>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { BambuLabCredentials, FTPUploadOptions, FTPUploadProgress, FileUploadResponse, FileListResponse, FileDeleteResponse } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* FTP Helper for Bambu Lab Printer File Operations
|
|
4
|
+
* Handles file upload, listing, and deletion via FTP/FTPS
|
|
5
|
+
*/
|
|
6
|
+
export declare class BambuLabFtpClient {
|
|
7
|
+
private client;
|
|
8
|
+
private credentials;
|
|
9
|
+
private connectionTimeout;
|
|
10
|
+
constructor(credentials: BambuLabCredentials);
|
|
11
|
+
/**
|
|
12
|
+
* Connect to the Bambu Lab printer via FTP/FTPS
|
|
13
|
+
*/
|
|
14
|
+
connect(): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Upload a file to the printer
|
|
17
|
+
* @param options Upload options including file content and destination
|
|
18
|
+
* @param progressCallback Optional callback for upload progress
|
|
19
|
+
*/
|
|
20
|
+
uploadFile(options: FTPUploadOptions, progressCallback?: (progress: FTPUploadProgress) => void): Promise<FileUploadResponse>;
|
|
21
|
+
/**
|
|
22
|
+
* List files in a directory on the printer
|
|
23
|
+
* @param remotePath Path to list (default: root directory)
|
|
24
|
+
*/
|
|
25
|
+
listFiles(remotePath?: string): Promise<FileListResponse>;
|
|
26
|
+
/**
|
|
27
|
+
* Delete a file from the printer
|
|
28
|
+
* @param remoteFilePath Full path to the file to delete
|
|
29
|
+
*/
|
|
30
|
+
deleteFile(remoteFilePath: string): Promise<FileDeleteResponse>;
|
|
31
|
+
/**
|
|
32
|
+
* Download a file from the printer
|
|
33
|
+
* @param remoteFilePath Path to the file on the printer
|
|
34
|
+
* @param localPath Local path to save the file
|
|
35
|
+
*/
|
|
36
|
+
downloadFile(remoteFilePath: string, localPath: string): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Create a directory on the printer
|
|
39
|
+
* @param remotePath Path to create
|
|
40
|
+
*/
|
|
41
|
+
createDirectory(remotePath: string): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Change the current working directory
|
|
44
|
+
* @param remotePath Path to change to
|
|
45
|
+
*/
|
|
46
|
+
changeDirectory(remotePath: string): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Get the current working directory
|
|
49
|
+
*/
|
|
50
|
+
getCurrentDirectory(): Promise<string>;
|
|
51
|
+
/**
|
|
52
|
+
* Check if connected to FTP server
|
|
53
|
+
*/
|
|
54
|
+
getConnectionStatus(): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Disconnect from the FTP server
|
|
57
|
+
*/
|
|
58
|
+
disconnect(): void;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=FtpHelper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FtpHelper.d.ts","sourceRoot":"","sources":["../../../../nodes/BambuLab/helpers/FtpHelper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,mBAAmB,EACnB,gBAAgB,EAEhB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,MAAM,SAAS,CAAC;AAGjB;;;GAGG;AACH,qBAAa,iBAAiB;IAC7B,OAAO,CAAC,MAAM,CAAY;IAE1B,OAAO,CAAC,WAAW,CAAsB;IAEzC,OAAO,CAAC,iBAAiB,CAAS;gBAEtB,WAAW,EAAE,mBAAmB;IAO5C;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAuB9B;;;;OAIG;IACG,UAAU,CACf,OAAO,EAAE,gBAAgB,EACzB,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,IAAI,GACtD,OAAO,CAAC,kBAAkB,CAAC;IA6E9B;;;OAGG;IACG,SAAS,CAAC,UAAU,SAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAyB5D;;;OAGG;IACG,UAAU,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAkBrE;;;;OAIG;IACG,YAAY,CAAC,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAc5E;;;OAGG;IACG,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYxD;;;OAGG;IACG,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAcxD;;OAEG;IACG,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC;IAY5C;;OAEG;IACH,mBAAmB,IAAI,OAAO;IAI9B;;OAEG;IACH,UAAU,IAAI,IAAI;CAKlB"}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BambuLabFtpClient = void 0;
|
|
4
|
+
const basic_ftp_1 = require("basic-ftp");
|
|
5
|
+
const stream_1 = require("stream");
|
|
6
|
+
/**
|
|
7
|
+
* FTP Helper for Bambu Lab Printer File Operations
|
|
8
|
+
* Handles file upload, listing, and deletion via FTP/FTPS
|
|
9
|
+
*/
|
|
10
|
+
class BambuLabFtpClient {
|
|
11
|
+
client;
|
|
12
|
+
credentials;
|
|
13
|
+
connectionTimeout = 15000; // 15 seconds
|
|
14
|
+
constructor(credentials) {
|
|
15
|
+
this.credentials = credentials;
|
|
16
|
+
this.client = new basic_ftp_1.Client(this.connectionTimeout);
|
|
17
|
+
// Enable verbose logging for debugging (can be disabled in production)
|
|
18
|
+
// this.client.ftp.verbose = true;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Connect to the Bambu Lab printer via FTP/FTPS
|
|
22
|
+
*/
|
|
23
|
+
async connect() {
|
|
24
|
+
try {
|
|
25
|
+
// Use FTPS (FTP over TLS) if the port is 990, otherwise plain FTP
|
|
26
|
+
const useFTPS = this.credentials.ftpPort === 990;
|
|
27
|
+
await this.client.access({
|
|
28
|
+
host: this.credentials.printerIp,
|
|
29
|
+
port: this.credentials.ftpPort,
|
|
30
|
+
user: 'bblp',
|
|
31
|
+
password: this.credentials.accessCode,
|
|
32
|
+
secure: useFTPS,
|
|
33
|
+
// Bambu Lab printers use self-signed certificates
|
|
34
|
+
secureOptions: {
|
|
35
|
+
rejectUnauthorized: false,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
throw new Error(`Failed to connect to FTP server at ${this.credentials.printerIp}:${this.credentials.ftpPort}: ${error.message}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Upload a file to the printer
|
|
45
|
+
* @param options Upload options including file content and destination
|
|
46
|
+
* @param progressCallback Optional callback for upload progress
|
|
47
|
+
*/
|
|
48
|
+
async uploadFile(options, progressCallback) {
|
|
49
|
+
if (this.client.closed) {
|
|
50
|
+
await this.connect();
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
const remotePath = options.remotePath || '/';
|
|
54
|
+
const remoteFilePath = `${remotePath}/${options.fileName}`.replace('//', '/');
|
|
55
|
+
// Track upload progress if callback is provided
|
|
56
|
+
if (progressCallback && options.fileContent) {
|
|
57
|
+
const totalBytes = typeof options.fileContent === 'string'
|
|
58
|
+
? Buffer.byteLength(options.fileContent)
|
|
59
|
+
: options.fileContent.length;
|
|
60
|
+
let bytesTransferred = 0;
|
|
61
|
+
this.client.trackProgress((info) => {
|
|
62
|
+
bytesTransferred = info.bytes;
|
|
63
|
+
progressCallback({
|
|
64
|
+
fileName: options.fileName,
|
|
65
|
+
bytesTransferred,
|
|
66
|
+
totalBytes,
|
|
67
|
+
percentage: Math.round((bytesTransferred / totalBytes) * 100),
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
// Upload from local file path
|
|
73
|
+
if (options.localPath) {
|
|
74
|
+
await this.client.uploadFrom(options.localPath, remoteFilePath);
|
|
75
|
+
}
|
|
76
|
+
// Upload from buffer or string
|
|
77
|
+
else if (options.fileContent) {
|
|
78
|
+
let stream;
|
|
79
|
+
if (typeof options.fileContent === 'string') {
|
|
80
|
+
stream = stream_1.Readable.from([options.fileContent]);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
stream = stream_1.Readable.from([options.fileContent]);
|
|
84
|
+
}
|
|
85
|
+
await this.client.uploadFrom(stream, remoteFilePath);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
throw new Error('Either localPath or fileContent must be provided');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
// Always stop tracking progress
|
|
93
|
+
this.client.trackProgress();
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
success: true,
|
|
97
|
+
message: `File ${options.fileName} uploaded successfully`,
|
|
98
|
+
fileName: options.fileName,
|
|
99
|
+
remotePath: remoteFilePath,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
const err = error;
|
|
104
|
+
if (err.message.includes('ECONNREFUSED') || err.message.includes('connect')) {
|
|
105
|
+
throw new Error(`Cannot connect to FTP server at ${this.credentials.printerIp}:${this.credentials.ftpPort}. Is the printer online and Developer Mode enabled?`);
|
|
106
|
+
}
|
|
107
|
+
else if (err.message.includes('530') || err.message.includes('Login')) {
|
|
108
|
+
throw new Error(`FTP authentication failed. Please verify your access code in the credentials.`);
|
|
109
|
+
}
|
|
110
|
+
else if (err.message.includes('550') || err.message.includes('permission')) {
|
|
111
|
+
throw new Error(`Permission denied. The printer may not allow file uploads to this location: ${options.remotePath}`);
|
|
112
|
+
}
|
|
113
|
+
throw new Error(`Failed to upload file: ${err.message}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* List files in a directory on the printer
|
|
118
|
+
* @param remotePath Path to list (default: root directory)
|
|
119
|
+
*/
|
|
120
|
+
async listFiles(remotePath = '/') {
|
|
121
|
+
if (this.client.closed) {
|
|
122
|
+
await this.connect();
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
const fileList = await this.client.list(remotePath);
|
|
126
|
+
const files = fileList.map((file) => ({
|
|
127
|
+
name: file.name,
|
|
128
|
+
type: file.isDirectory ? 'directory' : 'file',
|
|
129
|
+
size: file.size,
|
|
130
|
+
modifiedTime: file.modifiedAt,
|
|
131
|
+
permissions: file.permissions,
|
|
132
|
+
}));
|
|
133
|
+
return {
|
|
134
|
+
success: true,
|
|
135
|
+
files,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
throw new Error(`Failed to list files in ${remotePath}: ${error.message}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Delete a file from the printer
|
|
144
|
+
* @param remoteFilePath Full path to the file to delete
|
|
145
|
+
*/
|
|
146
|
+
async deleteFile(remoteFilePath) {
|
|
147
|
+
if (this.client.closed) {
|
|
148
|
+
await this.connect();
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
await this.client.remove(remoteFilePath);
|
|
152
|
+
return {
|
|
153
|
+
success: true,
|
|
154
|
+
message: `File ${remoteFilePath} deleted successfully`,
|
|
155
|
+
fileName: remoteFilePath.split('/').pop() || remoteFilePath,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
throw new Error(`Failed to delete file ${remoteFilePath}: ${error.message}`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Download a file from the printer
|
|
164
|
+
* @param remoteFilePath Path to the file on the printer
|
|
165
|
+
* @param localPath Local path to save the file
|
|
166
|
+
*/
|
|
167
|
+
async downloadFile(remoteFilePath, localPath) {
|
|
168
|
+
if (this.client.closed) {
|
|
169
|
+
await this.connect();
|
|
170
|
+
}
|
|
171
|
+
try {
|
|
172
|
+
await this.client.downloadTo(localPath, remoteFilePath);
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
throw new Error(`Failed to download file ${remoteFilePath}: ${error.message}`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Create a directory on the printer
|
|
180
|
+
* @param remotePath Path to create
|
|
181
|
+
*/
|
|
182
|
+
async createDirectory(remotePath) {
|
|
183
|
+
if (this.client.closed) {
|
|
184
|
+
await this.connect();
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
await this.client.ensureDir(remotePath);
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
throw new Error(`Failed to create directory ${remotePath}: ${error.message}`);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Change the current working directory
|
|
195
|
+
* @param remotePath Path to change to
|
|
196
|
+
*/
|
|
197
|
+
async changeDirectory(remotePath) {
|
|
198
|
+
if (this.client.closed) {
|
|
199
|
+
await this.connect();
|
|
200
|
+
}
|
|
201
|
+
try {
|
|
202
|
+
await this.client.cd(remotePath);
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
throw new Error(`Failed to change directory to ${remotePath}: ${error.message}`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Get the current working directory
|
|
210
|
+
*/
|
|
211
|
+
async getCurrentDirectory() {
|
|
212
|
+
if (this.client.closed) {
|
|
213
|
+
await this.connect();
|
|
214
|
+
}
|
|
215
|
+
try {
|
|
216
|
+
return await this.client.pwd();
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
throw new Error(`Failed to get current directory: ${error.message}`);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Check if connected to FTP server
|
|
224
|
+
*/
|
|
225
|
+
getConnectionStatus() {
|
|
226
|
+
return !this.client.closed;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Disconnect from the FTP server
|
|
230
|
+
*/
|
|
231
|
+
disconnect() {
|
|
232
|
+
if (!this.client.closed) {
|
|
233
|
+
this.client.close();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
exports.BambuLabFtpClient = BambuLabFtpClient;
|
|
238
|
+
//# sourceMappingURL=FtpHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FtpHelper.js","sourceRoot":"","sources":["../../../../nodes/BambuLab/helpers/FtpHelper.ts"],"names":[],"mappings":";;;AAAA,yCAAgD;AAUhD,mCAAkC;AAElC;;;GAGG;AACH,MAAa,iBAAiB;IACrB,MAAM,CAAY;IAElB,WAAW,CAAsB;IAEjC,iBAAiB,GAAG,KAAK,CAAC,CAAC,aAAa;IAEhD,YAAY,WAAgC;QAC3C,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,IAAI,kBAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACpD,uEAAuE;QACvE,kCAAkC;IACnC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO;QACZ,IAAI,CAAC;YACJ,kEAAkE;YAClE,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,KAAK,GAAG,CAAC;YAEjD,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;gBACxB,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,SAAS;gBAChC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,OAAO;gBAC9B,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC,UAAU;gBACrC,MAAM,EAAE,OAAO;gBACf,kDAAkD;gBAClD,aAAa,EAAE;oBACd,kBAAkB,EAAE,KAAK;iBACzB;aACD,CAAC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CACd,sCAAsC,IAAI,CAAC,WAAW,CAAC,SAAS,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,KAAM,KAAe,CAAC,OAAO,EAAE,CAC3H,CAAC;QACH,CAAC;IACF,CAAC;I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import type { BambuLabCredentials, PrinterStatus, CommandResponse, AnyCommand } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* MQTT Helper for Bambu Lab Printer Communication
|
|
5
|
+
* Handles connection, command publishing, and status subscription
|
|
6
|
+
*/
|
|
7
|
+
export declare class BambuLabMqttClient {
|
|
8
|
+
private client;
|
|
9
|
+
private credentials;
|
|
10
|
+
private reportTopic;
|
|
11
|
+
private requestTopic;
|
|
12
|
+
private messageBuffer;
|
|
13
|
+
private connectionTimeout;
|
|
14
|
+
private responseTimeout;
|
|
15
|
+
private updateCallback?;
|
|
16
|
+
constructor(credentials: BambuLabCredentials);
|
|
17
|
+
/**
|
|
18
|
+
* Connect to the Bambu Lab printer via MQTT
|
|
19
|
+
*/
|
|
20
|
+
connect(): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Publish a command to the printer
|
|
23
|
+
*/
|
|
24
|
+
publishCommand(command: AnyCommand, waitForResponse?: boolean): Promise<CommandResponse>;
|
|
25
|
+
/**
|
|
26
|
+
* Get current printer status
|
|
27
|
+
* Sends a "pushall" command and waits for the response
|
|
28
|
+
*/
|
|
29
|
+
getStatus(): Promise<PrinterStatus>;
|
|
30
|
+
/**
|
|
31
|
+
* Subscribe to printer status updates with a callback
|
|
32
|
+
* Useful for real-time monitoring
|
|
33
|
+
*/
|
|
34
|
+
subscribeToUpdates(callback: (status: PrinterStatus) => void): void;
|
|
35
|
+
/**
|
|
36
|
+
* Get the MQTT client instance (for advanced usage)
|
|
37
|
+
*/
|
|
38
|
+
getClient(): MqttClient | null;
|
|
39
|
+
/**
|
|
40
|
+
* Check if the client is connected
|
|
41
|
+
*/
|
|
42
|
+
isConnected(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Disconnect from the printer
|
|
45
|
+
*/
|
|
46
|
+
disconnect(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Force disconnect (immediate)
|
|
49
|
+
*/
|
|
50
|
+
forceDisconnect(): void;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=MqttHelper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MqttHelper.d.ts","sourceRoot":"","sources":["../../../../nodes/BambuLab/helpers/MqttHelper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,MAAM,CAAC;AACvD,OAAO,KAAK,EACX,mBAAmB,EACnB,aAAa,EAEb,eAAe,EACf,UAAU,EACV,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,qBAAa,kBAAkB;IAC9B,OAAO,CAAC,MAAM,CAA2B;IAEzC,OAAO,CAAC,WAAW,CAAsB;IAEzC,OAAO,CAAC,WAAW,CAAS;IAE5B,OAAO,CAAC,YAAY,CAAS;IAE7B,OAAO,CAAC,aAAa,CAAqB;IAE1C,OAAO,CAAC,iBAAiB,CAAS;IAElC,OAAO,CAAC,eAAe,CAAS;IAEhC,OAAO,CAAC,cAAc,CAAC,CAAkC;gBAE7C,WAAW,EAAE,mBAAmB;IAM5C;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAoE9B;;OAEG;IACG,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE,eAAe,UAAQ,GAAG,OAAO,CAAC,eAAe,CAAC;IAwG5F;;;OAGG;IACG,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC;IAsEzC;;;OAGG;IACH,kBAAkB,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,GAAG,IAAI;IASnE;;OAEG;IACH,SAAS,IAAI,UAAU,GAAG,IAAI;IAI9B;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;OAEG;IACH,UAAU,IAAI,IAAI;IASlB;;OAEG;IACH,eAAe,IAAI,IAAI;CAOvB"}
|