diff --git a/device_controller.php b/device_controller.php index c6d167a..3755d31 100644 --- a/device_controller.php +++ b/device_controller.php @@ -45,11 +45,13 @@ function device_controller() // 2. User checks for device waiting for authentication $result = $device->get_auth_request(); - $port = 5005; - $broadcast_string = "emonpi.local"; - $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); - socket_set_option($sock, SOL_SOCKET, SO_BROADCAST, 1); - socket_sendto($sock, $broadcast_string, strlen($broadcast_string), 0, '255.255.255.255', $port); + if (isset($enable_UDP_broadcast) && $enable_UDP_broadcast) { + $port = 5005; + $broadcast_string = "emonpi.local"; + $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); + socket_set_option($sock, SOL_SOCKET, SO_BROADCAST, 1); + socket_sendto($sock, $broadcast_string, strlen($broadcast_string), 0, '255.255.255.255', $port); + } } else if ($route->subaction=="allow" && $session['write']) { // 3. User allows device to receive authentication details