Jack_Zhou Posted September 8, 2022 Posted September 8, 2022 when i use c4:createserver or c4:createnetworkconnection it can't receive mulicast packages from network how could i receive? Quote
RyanE Posted September 8, 2022 Posted September 8, 2022 Below is a snippet from the "KNX Routing Gateway" driver, where it sets up the multicast connection for two-way communication with the Routing Gateway over multicast. Older versions of the Control4 OS (earlier than 2.10.3) required opening up a server socket just to listen for multicast and also creating a network connection to send multicast. This snippet opens the appropriate connections based on version. You would use C4:SendToNetwork the same as any other connection to send. To receive, use ReceivedFromNetwork, and if that is successful, ignore any data coming in from OnServerDataIn. It's a little janky, but it does work. RyanE function CreateMulticastConnection() -- KNX Default Multicast is at: 224.0.23.12:3671 local knx_multicast_addr = Properties["KNX Multicast Address"] or "224.0.23.12" local knx_multicast_port = tonumber(Properties["KNX Multicast Port"]) or 3671 -- Create Network Binding-based connection for multicast sending/receiving (MULTICAST-L)... if (IsVersionGreaterThan("2.10.3.0")) then C4:CreateNetworkConnection(MULTICAST_BINDING, knx_multicast_addr) C4:NetConnect(MULTICAST_BINDING, knx_multicast_port, "MULTICAST-L") -- New 'Listening' connection -- Try to join multicast group periodically until success. StartConnectionTimer() else -- Create Server Socket listener for KNX data... ('binding-based' connection only listens on multicast for OS 2.10.3 or greater) C4:CreateServer(knx_multicast_port, "", true) C4:CreateNetworkConnection(MULTICAST_BINDING, knx_multicast_addr) C4:NetConnect(MULTICAST_BINDING, knx_multicast_port, "MULTICAST") -- Legacy 'Send Only' connection end end Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.