Here’s a function I wrote to potentially solve the issue, but I can’t test it in my office since the IDE doesn’t work behind a firewall for whatever reason… (Have to dig into that later)
Can someone saavy with code test this and then set back the device NetworkId to be the debug’d string
private convertIPtoHex(ipAddress) { //expecting a string like xxx.xxx.xxx.xxx
//debuging ip addresses
log.debug “convert hit”
//ipAdddress = “10.0.0.5”
log.debug ipAddress
//String hex = ‘0x’ + ipAddress.tokenize( ‘.’ ).collect { String.format( ‘%02x’, it.toInteger() ) }.join()
String hex = ipAddress.tokenize( ‘.’ ).collect { String.format( ‘%02x’, it.toInteger() ) }.join()
log.debug hex
}
otherwise I’ll test it tonight when I get home.
The issue is simple, converting decimal “10” to Hex is “A” but for IP notation, it is “0A” because decimal “192” is “C0” so in order to cover the entire range of 1-255 you need a double byte HEX.
So when the hub is trying to match up a device at “0A000005” (10.0.0.5) and the deviceNetworkId is only “A000005” it won’t work.
Simple issue, just the code examples of how to convert a string IP to hex are all wrong.
The same issue was with port numbers which can range from 1-65535
So 80 would be “50” but really needs to read “0050”
Where as 5000 would be “1388” and works or 65534 would be “FFFE”
So the existing functions someone wrote to convert IP to Hex need to be fixed, along with ports.
Wouldn’t it just be easier to do this behind the scenes and let users enter standard IP and Port notation, 10.0.0.5:80?
Why make it so difficult.