dnadoba / sACN

sACN (E1.31) protocol implementation in Swift to send DMX Data over UDP using Network.framework
13 stars 4 forks source link
e131 ios macos network-framework sacn swift tvos udp

sACN (E1.31) Documentation

Swift Package for macOS, iOS, and tvOS to send sACN (E1.31) DMX Data over UDP using Network.framework.

Usage

You only need to initiate a Connection for a universe and you can start sending DMX Data.

let connection = Connection(universe: 1)
connection.sendDMXData(Data([0, 10, 255, 0, 0, 0, 255]))

If you want to use UDP Unicast instead of Multicast, you can simply specify an endpoint yourself:

let connection = Connection(endpoint: .hostPort(host: "192.168.2.102", .sACN), universe: 2)
connection.sendDMXData(Data([0, 10, 255, 0, 0, 0, 255]))

Features

Advanced Usage

Documentation

Using IPv6

For Unicast, you need to specify an IPv6 Endpoint. For Multicast, you need to specify the IP version you want to use:

let connection = Connection(universe: 1, ipVersion: .v6)

Priority

After you created a connection, you can set the priority per packet using the Connection.sendDMXData(_:priority:isPreviewData:) method. The default priority is 100.

connection.sendDMXData(data, priority: 200)

Preview Data

After you created a connection, you can choose per packet if it is preview data or not using the Connection.sendDMXData(_:priority:isPreviewData:) method. isPreviewData defaults to false.

connection.sendDMXData(data, isPreviewData: true)

Other Connection Initialization Configuration

Connection does support customizing the port, component identifier (CID), source name, DispatchQueue, and NWConneciton.Parameter. Look into the Documentation for more information.

public convenience init(
    universe: UInt16,
    ipVersion: IPVersion = .v4,
    port: NWEndpoint.Port = .sACN,
    cid: UUID = .init(),
    sourceName: String = getDeviceName(),
    queue: DispatchQueue? = nil,
    parameters: NWParameters? = nil
)

Known Limitations