HSL 2.0 framework Description of the framework

Public Member Functions |List of all members
hsl20_4_udp.hsl20_4_udp.Broadcast Class Reference

All methods for communication via UDP broadcast. More..

.

Inherits hsl20_4_udp.hsl20_4_udp.UdpBase

## Public Member Functions
def | set_address (self, ip, port)
| Sets the server address for the broadcast where data can be received. More...
def | send_to (self, data, ip, port)
| Sends data by broadcast to the specified address. More...
Public Member Functions inherited from hsl20_4_udp.hsl20_4_udp.UdpBase
def | __init__ (self, framework, context_map)
| Constructor. More...
def | set_on_data (self, callback)
| Sets a callback for data reception. More...
def | set_on_error (self, callback)
| Sets a callback in case of an error. More...
def | start_server (self)
| Starts the UDP receive server. More...

## Detailed Description

All methods for communication via UDP broadcast

Deprecated:
  This class should no longer be used

Provides communication via UDP/IP in both directions.

Is derived from UdpBase.

Example

class UDP_Client(hsl20_4.BaseModule):
def __init__(self, homeserver_context):
...
def on_init(self):
self.client = None
def on_input_value(self, index, value):
if index == self.PIN_I_DATA:
if self.client == None:
self.client = self.FRAMEWORK.create_udp_broadcast()
self.client.send_to(value, "192.168.0.255" , 4711)

The example includes a Broadcast UDP client. If a telegram arrives at input 1 (PIN_I_DATA), it is sent via UDP. Via inputs 2 (PIN_I_IP) and 3 (PIN_I_PORT) the broadcast IP and port are determined.

Note
  The class works asynchronously. None of the methods offered are blocked

## Member Function Documentation

## ◆ send_to()

def hsl20_4_udp.hsl20_4_udp.Broadcast.send_to | ( |  | self,
|  |  | data,
|  |  | ip,
|  |  | port
| ) |  |

Sends data by broadcast to the specified address

Parameters

  data | string Data to be sent by broadcast
  ip | string Broadcast IP
  port | int Broadcast port

## ◆ set_address()

def hsl20_4_udp.hsl20_4_udp.Broadcast.set_address | ( |  | self,
|  |  | ip,
|  |  | port
| ) |  |

Sets the server address for the broadcast where data can be received

Parameters

  ip | string IP address. If an empty string is specified, the data is received at the HomeServer network address
  port | int IP port where the data can be received and sent

Exceptions

  RuntimeError | If this method is called while the server is already started, a RuntimeError exception is thrown

The documentation for this class was generated from the following file:

- hsl20_4_udp.py