Fixed QR code generation for 'Open' networks. Update README.md to reflect QR function. Updated dependencies

This commit is contained in:
Glenn de Haan
2025-01-08 19:09:25 +01:00
parent 4d2933b752
commit 4691a900c3
4 changed files with 12 additions and 8 deletions

View File

@@ -16,9 +16,12 @@ const variables = require('./variables');
* @return {Promise<unknown>}
*/
module.exports = (buffer = false) => {
// Define QR Content based on Wi-Fi Security Standard
const qrText = variables.unifiSsidPassword !== '' ? `WIFI:S:${variables.unifiSsid};T:WPA;P:${variables.unifiSsidPassword};;` : `WIFI:S:${variables.unifiSsid};;`;
return new Promise((resolve) => {
if(!buffer) {
QRCode.toDataURL(`WIFI:S:${variables.unifiSsid};T:${variables.unifiSsidPassword !== '' ? 'WPA' : ''};P:${variables.unifiSsidPassword !== '' ? variables.unifiSsidPassword : ''};;`, { version: 4, errorCorrectionLevel: 'Q' }, (err, url) => {
QRCode.toDataURL(qrText, { version: 4, errorCorrectionLevel: 'Q' }, (err, url) => {
if(err) {
log.error(`[Qr] Error while generating code!`);
log.error(err);
@@ -27,7 +30,7 @@ module.exports = (buffer = false) => {
resolve(url);
});
} else {
QRCode.toBuffer(`WIFI:S:${variables.unifiSsid};T:${variables.unifiSsidPassword !== '' ? 'WPA' : ''};P:${variables.unifiSsidPassword !== '' ? variables.unifiSsidPassword : ''};;`, { version: 4, errorCorrectionLevel: 'Q' }, (err, buffer) => {
QRCode.toBuffer(qrText, { version: 4, errorCorrectionLevel: 'Q' }, (err, buffer) => {
if(err) {
log.error(`[Qr] Error while generating code!`);
log.error(err);