Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

  • I see four protocols on the publisher page: BACnet、HTTP、Modbus、Twilio

    I want to use UDP to send data out.
    I think he should be in the HTTP protocol option.
    But I can't find it. It seems Only TCP in there.

    Is there a way to send data using UDP protocol?


  • @cuihe said in is there have UDP in publisher?:

    I want to use UDP to send data out.

    Why? Presumably there is a service that you are trying to interact with? We need more information than just 'UDP'.


  • Hi cuihe,

    You would be able to instantiate a java.net.DatagramSocket in a script, for the most general ability to use UDP. But with details of why may come a better answer, as Jared suggests.


  • @jared-wiltshire @phildunlap thank you for reply!
    I know that mango provides a completely superior function to UDP.
    But the reality is that an old system only accepts control signals in the form of UDP, and queries its database to determine whether the control effect has been achieved.

    my old system use these code(c#), if you need to skip:

    //your code here
    private void opendoor(string DoorNumber)
            {
                string strDestinationIP = System.Configuration.ConfigurationSettings.AppSettings["DoorContoler"];
                string strMessage = string.Empty;
                if (DoorNumber.Equals("MainDoor"))
                    strMessage = System.Configuration.ConfigurationSettings.AppSettings["MainDoorOpen"];           
                if (strMessage.Equals(string.Empty)) return;
                UdpClient udpClient = new UdpClient();
                IPAddress destinationIP = IPAddress.Parse(strDestinationIP);
                IPEndPoint destination = new IPEndPoint(destinationIP, 18001);
                byte[] message = HexStringToByteArray(strMessage);
                udpClient.Send(message, message.Length, destination);
                udpClient.Close();
            }
    

  • OK got you. Here's a meta data source you can import and use, you will have to change the dataPointXid of the context point to an actual point in your system. Script formatted below -

    {
      "dataSources":[
        {
          "xid":"DS_464401cf-d4f5-42e4-abb3-5cf0e7b43c99",
          "name":"UDP test",
          "enabled":true,
          "type":"META",
          "alarmLevels":{
            "SCRIPT_ERROR":"URGENT",
            "CONTEXT_POINT_DISABLED":"URGENT",
            "RESULT_TYPE_ERROR":"URGENT"
          },
          "purgeType":"YEARS",
          "editPermission":"",
          "purgeOverride":false,
          "purgePeriod":1
        }
      ],
      "dataPoints":[
        {
          "xid":"DP_02608a5a-1785-41b5-bc57-231b6823d810",
          "name":"UDP string sender",
          "enabled":true,
          "loggingType":"ON_CHANGE",
          "intervalLoggingPeriodType":"MINUTES",
          "intervalLoggingType":"INSTANT",
          "purgeType":"YEARS",
          "pointLocator":{
            "dataType":"ALPHANUMERIC",
            "updateEvent":"NONE",
            "contextUpdateEvent":"CONTEXT_UPDATE",
            "context":[
              {
                "varName":"input",
                "dataPointXid":"DP_d7f134b2-3940-4cc1-b9b3-2cf153342078",
                "updateContext":true
              }
            ],
            "logLevel":"NONE",
            "variableName":"point",
            "scriptPermissions":"superadmin",
            "executionDelaySeconds":0,
            "logCount":5,
            "logSize":1.0,
            "script":"var value = input.value;\nif (value == null) {\n    return value;\n}\n\nvar socket = new java.net.DatagramSocket();\ntry {\n    var address = java.net.InetAddress.getByName(\"10.55.55.10\");\n    var port = 1241;\n    \n    var valueBytes = value.getBytes(java.nio.charset.StandardCharsets.UTF_8);\n    var packet = new java.net.DatagramPacket(valueBytes, valueBytes.length, address, port);\n    \n    socket.send(packet);\n} finally {\n    socket.close();\n}\n\nreturn value;",
            "settable":false,
            "updateCronPattern":""
          },
          "eventDetectors":[
          ],
          "plotType":"STEP",
          "rollup":"NONE",
          "unit":"",
          "simplifyType":"NONE",
          "chartColour":"",
          "chartRenderer":{
            "type":"TABLE",
            "limit":10
          },
          "dataSourceXid":"DS_464401cf-d4f5-42e4-abb3-5cf0e7b43c99",
          "defaultCacheSize":1,
          "deviceName":"UDP sender",
          "discardExtremeValues":false,
          "discardHighLimit":1.7976931348623157E308,
          "discardLowLimit":-1.7976931348623157E308,
          "intervalLoggingPeriod":1,
          "intervalLoggingSampleWindowSize":0,
          "overrideIntervalLoggingSamples":false,
          "preventSetExtremeValues":false,
          "purgeOverride":false,
          "purgePeriod":1,
          "readPermission":"",
          "setExtremeHighLimit":1.7976931348623157E308,
          "setExtremeLowLimit":-1.7976931348623157E308,
          "setPermission":"",
          "tags":{
          },
          "textRenderer":{
            "type":"PLAIN",
            "useUnitAsSuffix":false,
            "suffix":""
          },
          "tolerance":0.0
        }
      ]
    }
    

    Actual script

    var value = input.value;
    if (value == null) {
        return value;
    }
    
    var socket = new java.net.DatagramSocket();
    try {
        var address = java.net.InetAddress.getByName("10.55.55.10");
        var port = 1241;
        
        var valueBytes = value.getBytes(java.nio.charset.StandardCharsets.UTF_8);
        var packet = new java.net.DatagramPacket(valueBytes, valueBytes.length, address, port);
        
        socket.send(packet);
    } finally {
        socket.close();
    }
    
    return value;
    

  • I think I understand. Thank you very much!