mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 17:25:20 +00:00
chore(BLE): move connect/duty/announce constants to TransportConfig and reference them
This commit is contained in:
@@ -70,7 +70,7 @@ final class BLEService: NSObject {
|
|||||||
|
|
||||||
// Simple announce throttling
|
// Simple announce throttling
|
||||||
private var lastAnnounceSent = Date.distantPast
|
private var lastAnnounceSent = Date.distantPast
|
||||||
private let announceMinInterval: TimeInterval = 1.0
|
private let announceMinInterval: TimeInterval = TransportConfig.bleAnnounceMinInterval
|
||||||
|
|
||||||
// Application state tracking (thread-safe)
|
// Application state tracking (thread-safe)
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
@@ -129,8 +129,8 @@ final class BLEService: NSObject {
|
|||||||
private var maintenanceCounter = 0 // Track maintenance cycles
|
private var maintenanceCounter = 0 // Track maintenance cycles
|
||||||
|
|
||||||
// MARK: - Connection budget & scheduling (central role)
|
// MARK: - Connection budget & scheduling (central role)
|
||||||
private let maxCentralLinks = 6
|
private let maxCentralLinks = TransportConfig.bleMaxCentralLinks
|
||||||
private let connectRateLimitInterval: TimeInterval = 0.5
|
private let connectRateLimitInterval: TimeInterval = TransportConfig.bleConnectRateLimitInterval
|
||||||
private var lastGlobalConnectAttempt: Date = .distantPast
|
private var lastGlobalConnectAttempt: Date = .distantPast
|
||||||
private struct ConnectionCandidate {
|
private struct ConnectionCandidate {
|
||||||
let peripheral: CBPeripheral
|
let peripheral: CBPeripheral
|
||||||
@@ -147,8 +147,8 @@ final class BLEService: NSObject {
|
|||||||
// MARK: - Adaptive scanning duty-cycle
|
// MARK: - Adaptive scanning duty-cycle
|
||||||
private var scanDutyTimer: DispatchSourceTimer?
|
private var scanDutyTimer: DispatchSourceTimer?
|
||||||
private var dutyEnabled: Bool = true
|
private var dutyEnabled: Bool = true
|
||||||
private var dutyOnDuration: TimeInterval = 5
|
private var dutyOnDuration: TimeInterval = TransportConfig.bleDutyOnDuration
|
||||||
private var dutyOffDuration: TimeInterval = 10
|
private var dutyOffDuration: TimeInterval = TransportConfig.bleDutyOffDuration
|
||||||
private var dutyActive: Bool = false
|
private var dutyActive: Bool = false
|
||||||
|
|
||||||
// MARK: - Link capability snapshots (thread-safe via bleQueue)
|
// MARK: - Link capability snapshots (thread-safe via bleQueue)
|
||||||
|
|||||||
@@ -18,5 +18,11 @@ enum TransportConfig {
|
|||||||
// Timers
|
// Timers
|
||||||
static let networkResetGraceSeconds: TimeInterval = 600 // 10 minutes
|
static let networkResetGraceSeconds: TimeInterval = 600 // 10 minutes
|
||||||
static let basePublicFlushInterval: TimeInterval = 0.08 // ~12.5 fps batching
|
static let basePublicFlushInterval: TimeInterval = 0.08 // ~12.5 fps batching
|
||||||
}
|
|
||||||
|
|
||||||
|
// BLE duty/announce/connect
|
||||||
|
static let bleConnectRateLimitInterval: TimeInterval = 0.5
|
||||||
|
static let bleMaxCentralLinks: Int = 6
|
||||||
|
static let bleDutyOnDuration: TimeInterval = 5.0
|
||||||
|
static let bleDutyOffDuration: TimeInterval = 10.0
|
||||||
|
static let bleAnnounceMinInterval: TimeInterval = 1.0
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user