Iād like to send some UDP broadcast packets.
Is there any API for that?
Me too.. in fact I'd like to both send and receive them ...
@patrick.stuart can we have a sneak peek too?
me too .... probably for the same reason as @kevin
xAP still going strong then
We don't have UDP broadcast support exactly. If you want to test our UDP packet sending via hubaction, PM me and I can share some test code. It is in development and we'd love some feedback on it. The final version will most likely change, so we don't want to make the current code public just yet.
Since you linked to the Reddit topic I'd posted a while back, I figured I'd chime in with what I've learned about UDP (so far---I've only done some bare-bones testing, and haven't tested the 1.1.4 firmware). If we shouldn't be discussing this because it's not public, I completely understand and won't have a problem keeping quiet.
UDP has been pretty reliable for me. I haven't tested parsing returns yet. If you all get a sneak peak too, maybe you will get around to testing this before me.
As of my latest test, you can still only send String data, which means you're not going to be able to send Unsigned values (raw bytes above 0x7F) without getting extra encoding bytes in the mix. I've tried changing string encoding ... everything. Even considered creating a new encoding table --- but that just seems silly of me. I'd rather just wait for official integration. If anyone finds a way around this, it'd be game changing for me and I'd be all ears.
Perfectly fine to talk about it, we just don't want to share the code publicly yet as it is probably not final and make sure those testing it understand that.
@patrick Any updates on the availability of UDP? I'd like to take a stab at making local lifx control but doing that requires listening to and broadcasting UDP.
Yeah, I was wondering about this as well. To implement anything to control a DMX device we need UDP.
Here are some examples of sending UDP messages
For sending regular strings:
String message = "Hello"
def myHubAction = new hubitat.device.HubAction(message,
hubitat.device.Protocol.LAN,
[type: hubitat.device.HubAction.Type.LAN_TYPE_UDPCLIENT,
destinationAddress: "192.168.1.100:6628"])
sendHubCommand(myHubAction)
for sending binary messages (message back to parse will also be hex string encoded):
byte[] rawBytes = [0x71, 0x23, 0x0F, 0xA3]
String stringBytes = hubitat.helper.HexUtils.byteArrayToHexString(rawBytes)
def myHubAction = new hubitat.device.HubAction(stringBytes,
hubitat.device.Protocol.LAN,
[type: hubitat.device.HubAction.Type.LAN_TYPE_UDPCLIENT,
destinationAddress: "192.168.1.101:7815",
encoding: hubitat.device.HubAction.Encoding.HEX_STRING])
sendHubCommand(myHubAction)
HexUtils is documented here:
HexUtils
so is there a way to listen as well?
if you are asking about the hub receiving udp broadcasts from a device. No, we do not support that. You can only send out UDP messages and receive a reply to that message.
ok, thanks. would be nice to have in the future
I would like UDP receive too. One of the protocols I use extensively (xAP) uses it to a broadcast address.
I think that means: An App on the hub must initiate the UDP exchange. The "reply" will be seen in the parse method of that App. That might mean Lifx can be implemented locally.
Is there support for UDP unicast as well? The reason for asking is that the LIFX LAN protocol seems to recommend that unicast is used for addressing an individual bulb - although it looks as though broadcast might work as well but causing more wifi traffic than desirable.
The only difference between broadcast and unicast is the address you send to. The examples I posted above are unicast messages.
Great, thanks.
Would be nice to have listen capability too, i.e. parse to be called for every received packet on a specific port
Two items:
a. When is the UDP support going live so I can test direct command of the TP-Link devices? It would greatly simplify installation and operations.
b. Another item I may need is straight TCP support (i.e., "net.connect" in node.js) to a device. Does or will Hubitat support this?
Dave