Skip to content

UDP

Supported data types

  • bool
  • int
  • float
  • string
Data typeQVariant boolQVariant intQVariant floatQVariant string
UDP::bool
UDP::int
UDP::float
1
UDP::string
  1. float value are written to udp as a string

Configuration options

The minimal device config when using the default options would be:

settings.yml
devices:
- type: udp
name: udp1
options:
ip: 10.0.0.9

A complete config would look like this:


settings.yml
devices:
- type: udp
name: udp1
options:
ip: 10.0.0.1
port: 4242
terminate: true
allow_all_clients: true
clients:
- client1:
ip: 10.0.0.2
port: 1234
- client2:
ip: 10.0.0.3
port: 1234

where

type

is always “udp” as this is the name of this plugin.

name

unique arbitrary name.

options/ip

the ip address of the UDP server. (default: 0.0.0.0 (any))

options/port

the udp port the UDP server is listening on. (default: 6000)

options/terminate

terminates all strings with the null-terminator 0x00; does not apply to hex strings (defaults to false)

options/allow_all_clients

allows any client to send commands to this server. (default: false)

options/clients

a list of clients to send data to, and the clients that are allowed to send data to the server (when options.allow_all_clients is set to false, or omitted).

Output Mappings

An output mapping of type string will always send out the address, regardless of the input type. All other output types will send out the address + the value (int8, int16, string, bool, float (as string))

where

int8

Is a single byte 0x00 trough 0xff

int16

Is two bytes in big endian 0x0000 trough 0xffff

string

Is the ASCII string, or the raw hexadecimal string if formatted as such: Prefixed with 0x, which may be repeated and may contain spaces between bytes, but MUST start with 0x. e.g.: 0x4dca is equal to 0x4d ca and 0x4d 0xca. Furthermore: strings can use the turnary operator to send a different string dependent on the received input value. The syntax is prefix?ValueTrue:ValueFalse. This example will send a string prefixValueTrue if the received value is parsed as true, or prefixValueFalse if the received value is parsed as false. See the below examples for more details. If the prefix ends with %s the %s will be replaced with the received data.

bool

Is 0x01 for true and 0x00 for false

settings.yml
mappings:
- name: mapping1
from: { name: websocket, type: bool, address: sw1 } # <1>
to: { name: udp, type: string, address: 'outputstring' } # <2>
- name: mapping2 # <3>
from: { name: websocket, type: bool, address: sw1 }
to: { name: udp, type: string, address: '0x3df6ef' }
- name: mapping3 # <4>
from: { name: websocket, type: bool, address: sw1 }
to: { name: udp, type: string, address: 'state_?true:false' }
- name: mapping4 # <5>
from: { name: websocket, type: bool, address: sw1 }
to: { name: udp, type: string, address: '?play:pause' }
- name: mapping5 # <6>
from: { name: websocket, type: bool, address: sw1 }
to: { name: udp, type: string, address: '?0x3df6ef:0x3df6fa' }
- name: mapping6 # <7>
from: { name: websocket, type: bool, address: sw1 }
to: { name: udp, type: bool, address: prefix }
- name: mapping7 # <8>
from: { name: websocket, type: int8, address: ana8 }
to: { name: udp, type: int8, address: prefix }
- name: mapping7 # <9>
from: { name: websocket, type: int16, address: ana16 }
to: { name: udp, type: int16, address: prefix }
- name: mapping8 # <10>
from: { name: websocket, type: string, address: str1 }
to: { name: udp, type: string, address: prefix_%s }
  1. Websocket boolean input on address “sw1”, sends a value of true or false
  2. Every time the value on the websocket changes, the string outputstring is sent to the client, regardless of the value of sw1
  3. Identically as in
    2
    the same hexadecimal value will be sent to the client, regardless of the received value
  4. Using the ternary operator a different value can be specified whether the received value is true or false. In this example the string state_true is sent if sw1 becomes true, and the value state_false is sent if sw1 is false. The part before the ’?’ (state_ in this example) is prefixed in both cases, but can be left empty as well.
  5. As with
    4
    , here the string play is sent when sw1 becomes true, and pause is sent when sw1 is false
  6. Identically as in
    3
    , a different hexadecimal value is sent depending on the state of sw. In this case 0x3df6ef when true and 0x3df6fa when false
  7. When sending a boolean value the prefix is appended 0x01 when true or 0x00 when false. So when sw1 becomes true, the output will be 0x70726566697801 where 0x707265666978 is the hexadecimal encoded string ‘prefix’.
  8. When sending a 8bit integer value the prefix is appended 0x01 trough 0xff. So when ana8 has a value of 42, the output will be 0x7072656669782a where 0x707265666978 is the hexadecimal encoded string ‘prefix’ and 0x2a is 42 in hex.
  9. When sending a 16bit integer value the prefix is appended 0x0001 trough 0xffff. So when ana16 has a value of 1342, the output will be 0x707265666978053e where 0x707265666978 is the hexadecimal encoded string ‘prefix’ and 053e is 1342 in hex.
  10. when sending a string with an address ending in %s (here prefix_%s), the %s part will be replaced with the value send. So when the string value of hello world is sent over the websocket (on address str in this case), the output string prefix_hello world will be sent out to the udp clients.

Input Mappings

Input mappings are best explicitly specified in order to be parsed correctly.

settings.yml
mappings:
- name: mapping1
from: { name: udp, type: bool, address: sw1 } # <1>
to: { name: websocket, type: bool, address: sw1 } # <2>
- name: mapping2 # <3>
from: { name: udp, type: bool, address }
to: { name: websocket, type: bool, address: sw1 }
- name: mapping3 # <4>
from: { name: udp, type: int8, address: '0x34d7' }
to: { name: websocket, type: int8, address: lev1 }
- name: mapping4 # <5>
from: { name: udp, type: int16, address: '0x34d8' }
to: { name: websocket, type: int16, address: lev2 }
- name: mapping5 # <6>
from: { name: udp, type: string, address: 'cue_' }
to: { name: websocket, address: cue, type: float }
  1. udp input will receive boolean inputs with a prefix of sw1, e.g.: 0x73773101 will send out as true
  2. the value true will be sent to the websocket address sw1
  3. udp input without a prefix. 0x01 will be sent out as true, 0x00 will be sent out as false
  4. Input type int8, with an address of 0x34d7, will parse a received udp input payload 0x34d701 as value(01), payload 0x34d710 as value(16) and payload 0x34d7ff as value(255)
  5. Input type int16 will be processed as a 16bit integer (Big Endian notation), so with an address of 0x34d8 a received payload of 0x34d8ffff will be parsed and send out a value(65535) and a payload of 0x34d80010 as value(16)
  6. The received input string cue_13.2 will be sent out as a float 13.2, the address is removed from the received value prior to processing and converting its value.

NOTE

Since the address and value of an udp packet are combined in the same payload, you have to make sure that there are no overlaps possible in the addresses. e.g.: an input address of address and another one of address1 will overlap as they both start with address. When data comes in of the form address12 it would be unclear if this matches the address mapping with a value of 12 or the address4. In fact they’ll be both send out as such. To prevent this from happening, make sure you address them as address0 and address1, or address00 and address01 if you plan to go higher than 9. Or add a postfix that makes it unique (e.g.: address_ and address1_).