KnxRouterInterface

open class KnxRouterInterface: NSObject

Class representing the interface towards the KNX router.

  • Property to set for selecting connetion type

    Declaration

    Swift

    open static var connectionType: ConnectionType = .none
  • Property for setting the IP address of the KNX router

    Declaration

    Swift

    open static var routerIp: String?
  • Property for setting the port to connect to the KNX router on (defaults to port 6720.)

    Declaration

    Swift

    open static var routerPort: UInt16 = 6720
  • Property for setting the multicast group to join

    Declaration

    Swift

    open static var multicastGroup: String?
  • Property for setting the port for the multicast group

    Declaration

    Swift

    open static var multicastPort: UInt16 = 3671
  • Factory function to return an instance of a KnxRouterInterface.

    - In tcpDirect mode each call returns a new instance, while
    - in udpMulticast mode every call returns the same shared instance.
    

    Declaration

    Swift

    open static func getKnxRouterInstance() -> KnxRouterInterface?
  • Connect to a KNX router.

    Throws

    UnableToConnectToRouter

    Declaration

    Swift

    open func connect() throws
  • Disconnect from a KNX.

    Declaration

    Swift

    open func disconnect()
  • Subscribe for a group address.

    Declaration

    Swift

    open func subscribeFor(address: KnxGroupAddress,
                               responseHandler: KnxTelegramResponseHandlerDelegate)

    Parameters

    address

    The group address to subscrive to.

  • Send a write request telegram to a group address.

    Declaration

    Swift

    open func sendWriteRequest(to: KnxGroupAddress, type: KnxTelegramType, value:Any)

    Parameters

    to

    The group address to send to

    type

    The DPT to send

    value

    The value to send

  • Send a read request telegram to a group address.

    Declaration

    Swift

    open func sendReadRequest(to: KnxGroupAddress)
  • Response handler, called from the CocoaAsyncSocket framework upon connection.

    Declaration

    Swift

    @objc open func socket(_ socket: GCDAsyncSocket, didConnectToHost host: String, port: UInt16)

    Parameters

    socket

    The socket that did connect.

    didConnectToHost

    The name of the host that it has connected to.

    port

    The port that was connected on.

  • Response handler, called from the CocoaAsyncSocket framework upon reception of data.

    Declaration

    Swift

    @objc open func socket(_ socket: GCDAsyncSocket, didRead data: Data, withTag tag: Int)

    Parameters

    socket

    The socket that did connect.

    didReadData

    The received data.

    withTag

    The tag value supplied in the request to read.

  • Response handler, called from the CocoaAsyncSocket framework upon reception of data.

    Declaration

    Swift

    @objc open func socketDidDisconnect(_ sock: GCDAsyncSocket, withError err: Error?)

    Parameters

    socket

    The socket that did connect.

    err

    If the socket disconneted because of an error.

  • Response handler, called from the CocoaAsyncSocket framework upon reception of data.

    Declaration

    Swift

    open func udpSocket(_ sock: GCDAsyncUdpSocket, didReceive data: Data,
                            fromAddress address: Data, withFilterContext filterContext: Any?)

    Parameters

    sock

    The socket that the data was received on.

    data

    The received data.

    address

    The source address.

    filterContext

    The filter context used.

    err

    If the socket disconneted because of an error.