Fix username on mqtt config save

Set mqtt.address character limit to 62
This commit is contained in:
Garth Vander Houwen 2023-03-24 10:35:54 -07:00
parent 0a0f7f01cb
commit 93ffd8c72d
6 changed files with 133 additions and 32 deletions

View file

@ -79,8 +79,8 @@ struct MQTTConfig: View {
.onChange(of: address, perform: { _ in
let totalBytes = address.utf8.count
// Only mess with the value if it is too big
if totalBytes > 30 {
let firstNBytes = Data(username.utf8.prefix(30))
if totalBytes > 62 {
let firstNBytes = Data(username.utf8.prefix(62))
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
// Set the shortName back to the last place where it was the right size
address = maxBytesString