|
|
|
@ -13,14 +13,14 @@ import JL_BLEKit |
|
|
|
/// |
|
|
|
/// Initialization is idempotent — calling [initialize] twice returns |
|
|
|
/// immediately on the second call. |
|
|
|
public class JieliHomeServer { |
|
|
|
class JieliHomeServer { |
|
|
|
|
|
|
|
public static let shared = JieliHomeServer() |
|
|
|
static let shared = JieliHomeServer() |
|
|
|
|
|
|
|
private(set) public var initialized: Bool = false |
|
|
|
|
|
|
|
/// Event bus shared by Flutter EventChannel + native listeners. |
|
|
|
public let dispatcher: EventDispatcher = EventDispatcher() |
|
|
|
let dispatcher: EventDispatcher = EventDispatcher() |
|
|
|
|
|
|
|
// MARK: - Underlying SDK references |
|
|
|
// The JieLi iOS SDK exposes BLE plumbing via `JL_BLEMultiple` and per-device |
|
|
|
@ -34,36 +34,36 @@ public class JieliHomeServer { |
|
|
|
/// `JLTranslationManager`. Holds the active translation sink (call |
|
|
|
/// translation / assistant / device record); modules switch sinks as they |
|
|
|
/// enter/exit modes — only one mode at a time. |
|
|
|
public private(set) lazy var translationCoordinator: TranslationCoordinator = { |
|
|
|
private(set) lazy var translationCoordinator: TranslationCoordinator = { |
|
|
|
TranslationCoordinator(server: self) |
|
|
|
}() |
|
|
|
|
|
|
|
// MARK: - Features (lazy-attached after initialize) |
|
|
|
public private(set) lazy var scanFeature: ScanFeature = { |
|
|
|
private(set) lazy var scanFeature: ScanFeature = { |
|
|
|
ScanFeature(dispatcher: dispatcher) |
|
|
|
}() |
|
|
|
public private(set) lazy var connectFeature: ConnectFeature = { |
|
|
|
private(set) lazy var connectFeature: ConnectFeature = { |
|
|
|
ConnectFeature(server: self) |
|
|
|
}() |
|
|
|
public private(set) lazy var deviceInfoFeature: DeviceInfoFeature = { |
|
|
|
private(set) lazy var deviceInfoFeature: DeviceInfoFeature = { |
|
|
|
DeviceInfoFeature(server: self) |
|
|
|
}() |
|
|
|
public private(set) lazy var customCmdFeature: CustomCmdFeature = { |
|
|
|
private(set) lazy var customCmdFeature: CustomCmdFeature = { |
|
|
|
CustomCmdFeature(server: self) |
|
|
|
}() |
|
|
|
public private(set) lazy var translationFeature: TranslationFeature = { |
|
|
|
private(set) lazy var translationFeature: TranslationFeature = { |
|
|
|
TranslationFeature(server: self) |
|
|
|
}() |
|
|
|
public private(set) lazy var speechFeature: SpeechFeature = { |
|
|
|
private(set) lazy var speechFeature: SpeechFeature = { |
|
|
|
SpeechFeature(server: self) |
|
|
|
}() |
|
|
|
public private(set) lazy var otaFeature: OtaFeature = { |
|
|
|
private(set) lazy var otaFeature: OtaFeature = { |
|
|
|
OtaFeature(server: self) |
|
|
|
}() |
|
|
|
public private(set) lazy var deviceRecordFeature: DeviceRecordFeature = { |
|
|
|
private(set) lazy var deviceRecordFeature: DeviceRecordFeature = { |
|
|
|
DeviceRecordFeature(server: self) |
|
|
|
}() |
|
|
|
public private(set) lazy var assistantBridge: AssistantBridge = { |
|
|
|
private(set) lazy var assistantBridge: AssistantBridge = { |
|
|
|
AssistantBridge(server: self) |
|
|
|
}() |
|
|
|
|
|
|
|
@ -71,7 +71,7 @@ public class JieliHomeServer { |
|
|
|
|
|
|
|
// MARK: - Lifecycle |
|
|
|
|
|
|
|
public func initialize( |
|
|
|
func initialize( |
|
|
|
multiDevice: Bool, |
|
|
|
skipNoNameDev: Bool, |
|
|
|
enableLog: Bool |
|
|
|
@ -103,7 +103,7 @@ public class JieliHomeServer { |
|
|
|
]) |
|
|
|
} |
|
|
|
|
|
|
|
public func shutdown() { |
|
|
|
func shutdown() { |
|
|
|
if !initialized { return } |
|
|
|
otaFeature.cancel() |
|
|
|
deviceRecordFeature.stop() |
|
|
|
@ -116,11 +116,11 @@ public class JieliHomeServer { |
|
|
|
|
|
|
|
// MARK: - Native event subscription helpers |
|
|
|
|
|
|
|
public func addEventListener(_ listener: JieliEventListener) { |
|
|
|
func addEventListener(_ listener: JieliEventListener) { |
|
|
|
dispatcher.addNativeListener(listener) |
|
|
|
} |
|
|
|
|
|
|
|
public func removeEventListener(_ listener: JieliEventListener) { |
|
|
|
func removeEventListener(_ listener: JieliEventListener) { |
|
|
|
dispatcher.removeNativeListener(listener) |
|
|
|
} |
|
|
|
|
|
|
|
|