Meshtastic-Apple/Meshtastic/Accessory/Protocols/Connection.swift
jake-b 3f27e3b925
Keep list of previous manual connections (#1484)
* Keep list of previous manual connections

* More descriptive manual connection rows

* Merge fixes and new way to show IP on Connect view

---------

Co-authored-by: Jake-B <jake-b@users.noreply.github.com>
2025-10-28 06:18:17 -07:00

42 lines
897 B
Swift

//
// Connection.swift
// Meshtastic
//
// Created by Jake Bordens on 7/10/25.
//
import Foundation
import MeshtasticProtobufs
protocol Connection: Actor {
var type: TransportType { get }
var isConnected: Bool { get }
func send(_ data: ToRadio) async throws
func connect() async throws -> AsyncStream<ConnectionEvent>
func disconnect(withError: Error?, shouldReconnect: Bool) throws
func drainPendingPackets() async throws
func startDrainPendingPackets() throws
func appDidEnterBackground()
func appDidBecomeActive()
}
enum ConnectionEvent {
case data(FromRadio)
case logMessage(String)
case rssiUpdate(Int)
case error(Error)
case errorWithoutReconnect(Error)
case disconnected(shouldReconnect: Bool)
}
enum ConnectionState: Equatable, Codable {
case disconnected
case connecting
case connected
}
enum ConnectionError: Error, LocalizedError {
case ioError(String)
}