How to Send a UDP broadcast packet (no data) on port 30303 and parse() results for the responding device(s)

I was hoping to add 'device discovery' to a custom app I am developing. I have looked through many sendHubAction examples, but none seem to send a UDP broadcast packet (no data) on port 30303 so that the device's WiFi Module would respond.

Here is the details of what I need to accomplish. Any help, examples would be greatly appreciated.

The WiFi Module can be discovered on an network by sending a UDP broadcast packet (no data) on port 30303. The WiFi Module will respond with two ASCII-encoded lines of text, separated by CRLF. The first line is the hostname (BWGSPA, e.g.), and the second line is its MAC address. The OUI is 00:15:27. The IP address of the returned packet is the IP address of the WiFi module.

@thebearmay Would you be able to shed some light on this request or at least point me to a driver that has this type of LAN device discovery. I have racked my brains around using hubaction and you have many replies that provide great answers in threads I have searched.

Haven't tried it, but in theory you could send out a UDP message similar to the following

def sendDiscover(){
     cmd = null
     destPort = 30303
     new hubitat.device.HubAction(cmd,
              hubitat.device.Protocol.LAN,
              [type: hubitat.device.HubAction.Type.LAN_TYPE_UDPCLIENT,
              callback: parse,
              parseWarning: true,
              destinationPort: destPort])
}

def parse(message) {
....
}

And any return should show up in the parse method.

Wow, thank you for such a quick reply and the example code to execute. I did your example code as a test from a test driver and noting was returned to the parse method.

  1. Do I need to subscribe to a location/port or something to allow the lan devices time to respond?
  2. Also, should I be sending this on a broadcast ip of 255.255.255.255:30303.

Everything I'm reading says the code above should work. Could possibly increase the timeout to the max by changing the call to

     new hubitat.device.HubAction(cmd,
              hubitat.device.Protocol.LAN,
              [type: hubitat.device.HubAction.Type.LAN_TYPE_UDPCLIENT,
              callback: parse,
              parseWarning: true,
              destinationPort: destPort,
              timeout:300])

Might also try changing destPort to a string, i.e. destPort = '30303'

@thebearmay Thank you so much for your assistance,

At least I think your have the correct HE protocol statement, which I was trying several different types. But none get a response from the device.

It could be that the device using a wireless connection cannot receive/respond to broadcast packets. Perhaps my Netgear router defaults to preventing broadcast messages as in this documentation.

A Netgear router can block broadcast messages by utilizing a feature called "broadcast filtering" within its settings, which limits the number of broadcast packets that can be sent across the network, effectively preventing potential network disruptions caused by excessive broadcast traffic; you can access this feature through your router's web interface to enable or configure it depending on your need

I can test this using Python or other lan sniffing tools.

Again, thanks

1 Like