mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
* 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>
42 lines
897 B
Swift
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)
|
|
}
|