Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Sources/KitchenSyncApp/Discovery/DeviceMatch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ enum DeviceMatch {
/// P4, `kstouch-dfd0` on the Touch, `x32link-7a1c` on the headless (ESP-035). Missing
/// `kstouch` is what made a real device invisible once already.
private static func matchesKnownHostname(_ name: String) -> Bool {
knownHostPrefixes.contains { name.hasPrefix($0) }
let lower = name.lowercased() // a Bonjour instance name's case is not meaningful —
// the P4 advertises "KitchenSync", the Touch "kstouch-…"
return knownHostPrefixes.contains { lower.hasPrefix($0) }
}

/// `x32link` joined this list in ESP-035 — but adding it here was the SMALL half. That
Expand Down
10 changes: 10 additions & 0 deletions Tests/KitchenSyncAppTests/DeviceMatchTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ final class DeviceMatchTests: XCTestCase {
"a real Touch on the bench was invisible to the app because of this")
}

/// **A real P4 found this.** The ESP32-P4 advertises its Bonjour INSTANCE NAME as
/// "KitchenSync" (capital K, a friendly name), not the lowercase hostname the Touch
/// and X32Link use. hasPrefix is case-sensitive, so `"KitchenSync".hasPrefix(
/// "kitchensync")` is false and the P4 was invisible. A Bonjour name's case is not
/// meaningful; the match must be case-insensitive.
func test_the_p4_is_matched_despite_a_capitalised_instance_name() {
XCTAssertTrue(DeviceMatch.isKitchenSync(serviceName: "KitchenSync", txt: nil))
XCTAssertTrue(DeviceMatch.isKitchenSync(serviceName: "KSTouch-DFD0", txt: nil))
}

/// Units already in the field have no TXT record and won't until they're reflashed. Breaking
/// them would be a worse bug than the one being fixed.
func test_the_existing_devices_still_match_on_hostname() {
Expand Down
Loading