mirror of
https://github.com/glenndehaan/unifi-voucher-site.git
synced 2026-03-31 06:24:00 -04:00
Updated escpos_example.jpg screenshot. Implemented qr.js buffer toggle, Implemented ESC/POS Scan to Connect. Optimized ESC/POS layout. Implemented qr.js error logging
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 212 KiB After Width: | Height: | Size: 1.3 MiB |
@@ -186,9 +186,24 @@ module.exports = {
|
||||
printer.println(`${voucher.code.slice(0, 5)}-${voucher.code.slice(5)}`);
|
||||
printer.setTextNormal();
|
||||
|
||||
printer.newLine();
|
||||
printer.newLine();
|
||||
printer.newLine();
|
||||
if(variables.unifiSsid) {
|
||||
printer.newLine();
|
||||
printer.newLine();
|
||||
printer.newLine();
|
||||
|
||||
printer.alignLeft();
|
||||
printer.print('Connect to: ');
|
||||
printer.setTypeFontB();
|
||||
printer.setTextSize(1, 1);
|
||||
printer.print(variables.unifiSsid);
|
||||
printer.setTextNormal();
|
||||
printer.print(' or,');
|
||||
printer.newLine();
|
||||
printer.println('Scan to connect:');
|
||||
printer.alignCenter();
|
||||
await printer.printImageBuffer(await qr(true));
|
||||
}
|
||||
|
||||
printer.newLine();
|
||||
printer.newLine();
|
||||
|
||||
|
||||
@@ -6,17 +6,35 @@ const QRCode = require('qrcode');
|
||||
/**
|
||||
* Import own modules
|
||||
*/
|
||||
const log = require('./log');
|
||||
const variables = require('./variables');
|
||||
|
||||
/**
|
||||
* Generates a QR code from the UniFi SSID (Scan to Connect)
|
||||
*
|
||||
* @param buffer
|
||||
* @return {Promise<unknown>}
|
||||
*/
|
||||
module.exports = () => {
|
||||
module.exports = (buffer = false) => {
|
||||
return new Promise((resolve) => {
|
||||
QRCode.toDataURL(`WIFI:S:${variables.unifiSsid};T:;P:;;`, (err, url) => {
|
||||
resolve(url);
|
||||
});
|
||||
if(!buffer) {
|
||||
QRCode.toDataURL(`WIFI:S:${variables.unifiSsid};T:;P:;;`, { version: 4, errorCorrectionLevel: 'Q' }, (err, url) => {
|
||||
if(err) {
|
||||
log.error(`[Qr] Error while generating code!`);
|
||||
log.error(err);
|
||||
}
|
||||
|
||||
resolve(url);
|
||||
});
|
||||
} else {
|
||||
QRCode.toBuffer(`WIFI:S:${variables.unifiSsid};T:;P:;;`, { version: 4, errorCorrectionLevel: 'Q' }, (err, buffer) => {
|
||||
if(err) {
|
||||
log.error(`[Qr] Error while generating code!`);
|
||||
log.error(err);
|
||||
}
|
||||
|
||||
resolve(buffer);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user