Three commands (SetGroup, SetLabel, SetLocation) were calling something like .padding(toLength: 32, withPad: "", startingAt: 0) which is not necessary because DataOutputStream already takes a length for writeString and pads appropriately.
func writeString(value:String, size:Int){
let padding = size - value.utf8.count
for _ in 0..<padding{
writeByte(value: 20)
}
value.utf8.forEach{ writeByte(value: UInt8($0)) }
}
Also, if the string passed into any of these commands actually was too short, it would result in a crash, which you can reproduce by pasting the following line into a Swift Playground (can't actually pad with an empty string like that)
let padded = "Hello World".padding(toLength: 32, withPad: "", startingAt: 0)
With this fix, I am able to properly rename bulbs now in my host app.
Three commands (SetGroup, SetLabel, SetLocation) were calling something like .padding(toLength: 32, withPad: "", startingAt: 0) which is not necessary because DataOutputStream already takes a length for writeString and pads appropriately.
Also, if the string passed into any of these commands actually was too short, it would result in a crash, which you can reproduce by pasting the following line into a Swift Playground (can't actually pad with an empty string like that)
With this fix, I am able to properly rename bulbs now in my host app.