sgade/swift-desktopia
Control your [Desktopia Pro X](https://www.ergotopia.de/ergonomie-shop/hoehenverstellbarer-schreibtisch/desktopia-pro-x) from Swift.
π Getting Started
Add swift-desktopia as a dependency to your Package.swift:
let package = Package(
// name, platforms, products, etc.
dependencies: [
// other dependencies
.package(url: "https://github.com/sgade/swift-desktopia", from: "1.0.0"),
],
targets: [
.executableTarget(
name: "<your target>",
dependencies: [
// other dependencies
.product(name: "DesktopiaProX", package: "swift-desktopia"),
]
),
// other targets
]
)π― Connecting to the desk
Connect your device to the desk controller via the USB connection, and then find the device name for that connection. Since it is a serial connection, you will need to find the corresponding device on your file system.
On macOS, these devices are usually called something like /dev/cu.usbserial-X, where X is a number.
With that device name, you can create a connection to the desk:
import DesktopiaProX
let desk = Desk(port: "/dev/cu.usbserial-123", keepAlive: true)
try await desk.connect()The connection to the desk is in both ways, so you can send commands and the desk can send commands on its own.
π€ Reading commands from the desk
You can get a stream of commands to read:
Task {
let stream = try await desk.readCommands()
for await command in stream {
// interpret command...
}
}β¨ Sending commands to the desk
To send commands to the desk, all you need to do is:
try await desk.send(command: .showStatus)π The Desktopia Pro X protocol
The protocol has been reverse engineered from the official app (beta). Contributions and corrections are welcome.
License
See LICENSE.
Package Metadata
Repository: sgade/swift-desktopia
Default branch: main
README: README.md