mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Agent-Logs-Url: https://github.com/meshtastic/Meshtastic-Apple/sessions/5b7576a8-e0c0-4036-8b7e-8f2e6fbfa4d7 Co-authored-by: garthvh <1795163+garthvh@users.noreply.github.com>
42 lines
903 B
Swift
42 lines
903 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) async 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)
|
|
}
|