Swiftpack.co - bjtj/swift-upnp-tools as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by bjtj.
bjtj/swift-upnp-tools 0.1.16
Swift UPnP Tool
⭐️ 8
🕓 4 days ago
.package(url: "https://github.com/bjtj/swift-upnp-tools.git", from: "0.1.16")

SwiftUpnpTools

Swift Build Status

This is a swift upnp tool (library) mainly depends on IBM BlueSocket (https://github.com/IBM-Swift/BlueSocket).

Swift version

$ swift --version
Swift version 4.2.3 (swift-4.2.3-RELEASE)
Target: x86_64-unknown-linux-gnu
$ swift --version
Swift version 5.5 (swift-5.5-RELEASE)
Target: x86_64-unknown-linux-gnu

Dependencies

Build, Test

swift build
swift test

How to use it?

Add it to dependency (package.swift)

dependencies: [
    .package(url: "https://github.com/bjtj/swift-upnp-tools.git", from: "0.1.13"),
  ],

Import package into your code

import SwiftUpnpTools

Sample application code (UPnPControlPoint)

https://github.com/bjtj/swift-upnp-app/blob/master/Sources/swift-upnp-app/main.swift

Examples

Check out /Samples please.

UPnPControlPoint

let cp = UPnPControlPoint(port: 0)
cp.onDeviceAdded {
    (device) in
	
	...
}

cp.onScpd {
	(service, scpd, error) in
	
	...
}

try cp.run()

cp.sendMsearch(st: "ssdp:all", mx: 3)

...

cp.finish()

UPnPServer

let server = UPnPServer(port: 0)
server.run()

guard let device = UPnPDevice.read(xmlString: deviceDescription) else {
    return
}

server.registerDevice(device: device)
server.onActionRequest {
    (service, soapRequest) in
	
    let properties = OrderedProperties()
    properties["GetLoadlevelTarget"] = "10"
    return properties
}

...

server.finish()

GitHub

link
Stars: 8
Last commit: 2 days ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics