Repository navigation
feat(mqtt): add MQTT exporter, Home Assistant auto-discovery, and live streaming - #148
Open
foureight84 wants to merge 2 commits into
Open
foureight84 wants to merge 2 commits into
foureight84 wants to merge 2 commits into
Conversation
…e streaming Port Android PR saksham2001#147's standalone MQTT 3.1.1 integration to iOS: - Pure-Swift MQTT 3.1.1 wire protocol (CONNECT, CONNACK, PUBLISH QoS 0/1, PUBACK, PINGREQ/PINGRESP, DISCONNECT) with unit tests. - Native Network.framework (NWConnection) client supporting TCP, TLS (mqtts://), and WebSocket (ws:// / wss://) with a serialized session pool and stale-socket retry. - Keychain-backed broker password storage (MqttPrefsStore) and UserDefaults prefs. - Home Assistant auto-discovery and capability/data-gated state payloads (MqttDiscovery). - SwiftData snapshot collector (MqttExporter) and coalesced live/periodic publisher (MqttSyncPublisher). - Settings -> MQTT configuration screen (MqttSettingsView).
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports the standalone MQTT 3.1.1 integration from PulseLoopAndroid (PR #147) to iOS.
Summary
MqttProtocol.swift): Pure-Swift encoder/decoder forCONNECT,CONNACK,PUBLISH(QoS 0/1, retain/dup),PUBACK,PINGREQ/PINGRESP, andDISCONNECT.Network.frameworktransport (MqttClient.swift):NWConnection-backed client supporting TCP, TLS (mqtts://), and WebSocket (ws:///wss://, including IPv6 literals) with task-cancellation safety, plus a serializedMqttSessionPoolwith stale-socket retry for live streaming.MqttPrefsStore.swift,MqttSettingsView.swift): Stores broker preferences inUserDefaultsand the broker password in Keychain (com.pulseloop.mqtt), wired into Settings → Resources → MQTT (AppRoute.settingsMqtt).MqttDiscovery.swift): Capability- and data-gated sensor descriptors (includingbinary_sensorfor active workouts and hardware-only gating for stress/respiratory rate/VO2max), removal tombstones for stale sensors, and JSON state payloads.MqttExporter.swift,MqttSyncPublisher.swift,PulseLoopApp.swift): Reads real (non-demo/mock) SwiftData metrics via bounded per-kind queries and publishes offPulseDataChange.shared.tokenandscenePhaseedges (~5 s live debounce or configurable 15–720 min periodic interval).Verification
xcodebuild test -project PulseLoop.xcodeproj -scheme PulseLoop -destination 'platform=iOS Simulator,name=iPhone 17' -only-testing:PulseLoopTests/MqttProtocolTests -only-testing:PulseLoopTests/MqttDiscoveryTests -only-testing:PulseLoopTests/MqttPrefsStoreTests -only-testing:PulseLoopTests/MqttExporterTests— 15/15 tests passed.