Skip to content

acumen-dev/hap-swift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hap-swift

A native Swift implementation of the HomeKit Accessory Protocol (HAP) — the TCP-based protocol Apple Home uses for SecuritySystem, GarageDoorOpener, and other device types that Matter does not support.

Overview

Matter (spec 1.0–1.5) has no SecuritySystem or GarageDoorOpener device type. HAP fills that gap, letting Acumen advertise security panels and garage doors to Apple Home alongside Matter devices on the same network.

Both HAP and Matter use mDNS/DNS-SD for discovery via the shared mdns-swift package. HAP uses TCP transport; Matter uses UDP — the transport layers are separate.

Module Architecture

HAPCore          — HAP types, TLV8, constants, service/characteristic definitions
    ↑
HAPCrypto        — SRP-6a (3072-bit), Curve25519, ChaCha20-Poly1305, HKDF-SHA512
    ↑
HAPTransport     — TCP server, pairing state machine, encrypted sessions, characteristic protocol
    ↑
├── HAPApple     — Network.framework TCP + MDNSApple  (Apple platforms)
└── HAPLinux     — SwiftNIO TCP + MDNSLinux            (Linux)

HAPSwift         — Umbrella re-export

Usage

import HAPSwift

// Create a SecuritySystem accessory
let accessory = HAPAccessory(
    info: AccessoryInfo(
        name: "Front Panel",
        manufacturer: "Acumen",
        model: "SecuritySystem",
        serialNumber: "001",
        firmwareVersion: "1.0"
    ),
    category: .securitySystem,
    services: [securitySystemService]
)

// Advertise and serve via HAP
let bridge = HAPBridge(setupCode: "031-45-154")
bridge.addAccessory(accessory)
try await bridge.start()

Platform Requirements

Platform Minimum
macOS 15
iOS 18
tvOS 18
watchOS 11
visionOS 2
Linux Swift 6.2

Dependencies

Package Use
acumen-dev/mdns-swift mDNS advertisement (_hap._tcp)
apple/swift-crypto SRP-6a, Curve25519, ChaCha20-Poly1305
apple/swift-log Structured logging
apple/swift-nio TCP transport (Linux)

Adding to Your Package

dependencies: [
    .package(url: "https://github.com/acumen-dev/hap-swift.git", from: "1.0.0"),
],
targets: [
    .target(name: "MyTarget", dependencies: [
        .product(name: "HAPSwift", package: "hap-swift"),
    ]),
]

License

Apache 2.0 — see LICENSE.md.

About

Native Swift implementation of the HomeKit Accessory Protocol (HAP)

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages