Skip to content

Commit

Permalink
Fixed wlan bug with no password wifi
Browse files Browse the repository at this point in the history
Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
  • Loading branch information
Hilbrand committed Mar 28, 2022
1 parent 7b09c6e commit 8200b61
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,10 @@ public void setPortconfId(final String portconfId) {
public void setPoeMode(final String poeMode) {
this.poeMode = poeMode;
}

@Override
public String toString() {
return String.format("UnfiPortOverride{portIx: '%d', portconfId: '%s', poeMode: '%s'}", portIdx, portconfId,
poeMode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public Integer getExperience() {
@Override
public String toString() {
return String.format(
"UniFiClient{id: '%s', mac: '%s', ip: '%s', hostname: '%s', alias: '%s', wired: %b, guest: %b, blocked: %b, device: %s, experience: %d}",
id, mac, getIp(), hostname, alias, isWired(), guest, blocked, getDevice(), experience);
"UniFiClient{id: '%s', mac: '%s', ip: '%s', hostname: '%s', alias: '%s', wired: %b, guest: %b, blocked: %b, experience: %d, device: %s}",
id, mac, getIp(), hostname, alias, isWired(), guest, blocked, experience, getDevice());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ public void addPortOverride(final UnfiPortOverride unfiPortOverride) {
public void addPortOverride(final int portIdx, final String portconfId, final String poeMode) {
portOverrides.add(new UnfiPortOverride(portIdx, portconfId, poeMode));
}

@Override
public String toString() {
return String.format("UniFiPortOverrides: {}", String.join(", ", portOverrides.toArray(new String[0])));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,11 @@ public String getPoeVoltage() {
public String getPoeCurrent() {
return poeCurrent;
}

@Override
public String toString() {
return String.format(
"UniFiPortTable{name: '%s', enable: '%b', up: '%b', portPoe: '%b', poeEnable: '%b, poePower: '%s', poeVoltage: '%s', poeCurrent: '%s'}",
name, enable, up, portPoe, poeEnable, poePower, poeVoltage, poeCurrent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ public boolean matchesName(final String siteName) {

@Override
public String toString() {
return String.format("UniFiSite{name: '%s', desc: '%s'}", name, desc);
return String.format("UniFiSite{id: '%s', name: '%s', desc: '%s'}", id, name, desc);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,14 @@ public String getXPassphrase() {
public boolean isHideSsid() {
return Boolean.TRUE.equals(hideSsid);
}

@Override
public String toString() {
final String xPassphraseString = xPassphrase == null ? ""
: (xPassphrase.substring(0, Math.min(5, xPassphrase.length())) + "*".repeat(10));

return String.format(
"UniFiWlan{id: '%s', name: '%s', enable: '%b', security: '%s', wlanBand: '%s', wpaEnc: '%s', wpaMode: '%s', xPassphrase: '%s', hideSsid: '%b', site: '%s'}",
id, name, enabled, security, wlanBand, wpaEnc, wpaMode, xPassphraseString, hideSsid, getSite());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,17 @@ private static State countClients(final UniFiWlan wlan, final Function<UniFiClie
*/
private static State qrcodeEncoding(final UniFiWlan wlan) {
final String name = encode(wlan.getName());
final boolean nopass = wlan.getXPassphrase().isBlank();
final String xPassphrase = wlan.getXPassphrase();
final boolean nopass = xPassphrase == null || xPassphrase.isBlank();
final String mode = nopass ? "nopass" : "WPA";
final String hidden = wlan.isHideSsid() ? "H:true" : "";
final String passcode = nopass ? "" : "P:" + encode(wlan.getXPassphrase());
final String passcode = nopass ? "" : "P:" + encode(xPassphrase);

return StringType.valueOf(String.format("WIFI:S:%s;T:%s;%s;%s;", name, mode, passcode, hidden));
}

private static String encode(final String string) {
return string.replaceAll("([\\;,\":])", "\\\\$1");
private static String encode(final @Nullable String value) {
return value == null ? "" : value.replaceAll("([\\;,\":])", "\\\\$1");
}

@Override
Expand Down

0 comments on commit 8200b61

Please sign in to comment.