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
11 changes: 8 additions & 3 deletions Sources/KitchenSyncApp/Discovery/DeviceMatch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,16 @@ enum DeviceMatch {
/// units working, not because it is correct.
///
/// The firmware advertises generic `_http._tcp` with no TXT record, so the hostname is all a
/// client has. `ks_hostname()` builds `<product>-<last two MAC bytes>`: `kitchensync-a4f2` on
/// the P4, `kstouch-dfd0` on the Touch. Missing `kstouch` is what made a real device invisible.
/// client has. The hostname is `<product>-<last two MAC bytes>`: `kitchensync-a4f2` on the
/// 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) }
}

private static let knownHostPrefixes = ["kitchensync", "kstouch"]
/// `x32link` joined this list in ESP-035 — but adding it here was the SMALL half. That
/// unit had no mDNS whatsoever: it never advertised, so no matcher could have found it.
/// The user saw it exactly that way — "I see kstouch, not the headless" — while the box
/// sat there powered, on the network, and following the session.
private static let knownHostPrefixes = ["kitchensync", "kstouch", "x32link"]
}
17 changes: 17 additions & 0 deletions Tests/KitchenSyncAppTests/DeviceMatchTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,21 @@ final class DeviceMatchTests: XCTestCase {
txt: ["dev": "some-other-product"]),
"a TXT record that says it ISN'T ours must beat a hostname that says it is")
}

/// ESP-035: the headless X32Link. It was the last unit in the fleet with NO mDNS at
/// all -- it never advertised, so it could not be found no matter what this matcher
/// did. Now it announces `x32link-<mac>`, and the prefix list has to know the name.
///
/// The user hit this exactly: "I see kstouch. not the headless." The device was
/// powered, on the network, and following the Link session.
func test_the_headless_x32link_is_one_of_ours() {
XCTAssertTrue(DeviceMatch.isKitchenSync(serviceName: "x32link-7a1c", txt: nil))
}

/// The prefix is still a HEURISTIC, and it must not swallow the whole network. A
/// stranger's box at a venue is not ours.
func test_a_stranger_is_still_not_one_of_ours() {
XCTAssertFalse(DeviceMatch.isKitchenSync(serviceName: "brother-printer", txt: nil))
XCTAssertFalse(DeviceMatch.isKitchenSync(serviceName: "x32-mixer", txt: nil))
}
}
Loading