iOS/Sources/MacBridge/MacBridgeNetworkConnectivityImpl.swift
Zac West ee02799ac6
Allow Network Hardware Address to decide "internal" on Mac (#1370)
Fixes #1353.

## Summary
This allows you to use a docked ethernet adapter as the thing to decide whether you are currently internal. This will help hardware without Wi-Fi or with Wi-Fi disabled to use the feature.

## Screenshots
<img width="400" alt="Screen Shot 2021-01-12 at 20 26 28" src="https://user-images.githubusercontent.com/74188/104407176-df106580-5515-11eb-82a0-2b5d4eb23694.png"><img width="400" alt="Screen Shot 2021-01-12 at 20 26 23" src="https://user-images.githubusercontent.com/74188/104407181-e0da2900-5515-11eb-9c2c-773c725cb841.png">

## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a corresponding pull request in the Companion App Documentation repository (https://github.com/home-assistant/companion.home-assistant). Please add the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes
- Removes some "is this internal?" dead code during onboarding. Probably worth doing the internal/external pull in at this point.
- Pulls some of the class method things on ConnectionInfo into the connectivity wrapper in Environment.
2021-01-12 21:18:37 -08:00

41 lines
1.0 KiB
Swift

import Foundation
@objc final class MacBridgeNetworkConnectivityImpl: NSObject, MacBridgeNetworkConnectivity {
let networkType: MacBridgeNetworkType
let hasWiFi: Bool
let wifi: MacBridgeWiFi?
let interface: MacBridgeNetworkInterface?
init(
networkType: MacBridgeNetworkType,
hasWiFi: Bool,
wifi: MacBridgeWiFi?,
interface: MacBridgeNetworkInterface?
) {
self.networkType = networkType
self.wifi = wifi
self.hasWiFi = hasWiFi
self.interface = interface
}
}
@objc final class MacBridgeWiFiImpl: NSObject, MacBridgeWiFi {
let ssid: String
let bssid: String
init(ssid: String, bssid: String) {
self.ssid = ssid
self.bssid = bssid
}
}
@objc final class MacBridgeNetworkInterfaceImpl: NSObject, MacBridgeNetworkInterface {
let name: String
let hardwareAddress: String
init(name: String, hardwareAddress: String) {
self.name = name
self.hardwareAddress = hardwareAddress.lowercased()
}
}