SwiftUpnpTools

master

Swift UPnP Tool
bjtj/swift-upnp-tools

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()

Description

  • Swift Tools 4.2.0
View More Packages from this Author

Dependencies

Last updated: Wed Nov 13 2024 04:02:29 GMT-1000 (Hawaii-Aleutian Standard Time)