Skip to content

align code with changes from unique-ids commit 5af449d from itsmojo#5

Merged
ps2 merged 3 commits into
LoopKit:devfrom
marionbarker:dev-unique-ids
Jan 29, 2022
Merged

align code with changes from unique-ids commit 5af449d from itsmojo#5
ps2 merged 3 commits into
LoopKit:devfrom
marionbarker:dev-unique-ids

Conversation

@marionbarker
Copy link
Copy Markdown
Collaborator

Unique controller ids support, working eap seq # podIds

  • persistent id created at startup or deactvation as needed
  • eap seq # now incremented for each new session
  • podId #'s now cycle between next of 3 values on deactivate
  • temp fake podState no longer used to implement pairing

Unique controller ids support, working eap seq # podIds
* persistent id created at startup or deactvation as needed
* eap seq # now incremented for each new session
* podId #'s now cycle between next of 3 values on deactivate
* temp fake podState no longer used to implement pairing
@marionbarker
Copy link
Copy Markdown
Collaborator Author

This code compiled and built and passed the simulator test.
The code itsmojo started with is on a different tree so needed some manual work to make it compatible with dev.
Joe's unique-ids branch was merged into the freeaps_dash_wip branch of marionbarker OmniBLE.

A transfer branch, dev-unique-ids, was created in line with LoopKit OmniBLE dev branch commit 14ae79a.
Then modifications were made based on the 11 files updated in unique-ids.

Of the 11 files affected, 6 (i.e., 1, 2, 3, 4, 6 and 7) could be modified by git diff > txt; git apply txt in the two different folders holding the code on my computer. The other 5 were edited looking at the two versions side-by-side in xcode and using each individual diff as a guide.:

$ git branch
* freeaps_dash_wip

$ git diff --name-status 51aaa91 2a658c8
01 M       OmniBLE/Bluetooth/Id.swift
02 M       OmniBLE/Bluetooth/Ids.swift
03 M       OmniBLE/Bluetooth/MessagePacket.swift
04 M       OmniBLE/Bluetooth/Pair/PairMessage.swift
05 M       OmniBLE/Bluetooth/PeripheralManager+OmniBLE.swift
06 M       OmniBLE/Bluetooth/Session/SessionEstablisher.swift
07 M       OmniBLE/PumpManager/MessageTransport.swift
08 M       OmniBLE/PumpManager/OmniBLEPumpManager.swift
09 M       OmniBLE/PumpManager/OmniBLEPumpManagerState.swift
10 M       OmniBLE/PumpManager/PodComms.swift
11 M       OmniBLE/PumpManager/PodState.swift

@ps2 ps2 merged commit 5f533c6 into LoopKit:dev Jan 29, 2022
ps2 added a commit that referenced this pull request Aug 15, 2023
marionbarker added a commit that referenced this pull request Apr 6, 2024
put Silence Pod and Pod Diagnostics behind build-time flag
vanzaam pushed a commit to vanzaam/OmniBLE that referenced this pull request Apr 16, 2026
threecee pushed a commit to threecee/OmniBLE that referenced this pull request May 2, 2026
…LoopKit#5)

Adds 3 sub-tests (one per gate) to WatchAlgorithmEndToEndTests, each
running the full algorithm iteration with one gate set to "fail" and
asserting that:
- pod insulinDelivered did NOT change
- no temp basal was installed (basalDeliveryState != .tempBasal)

Gates covered:
- testGateSuppression_warmingUp_noDoseEnacted
- testGateSuppression_automaticDosingDisabled_noDoseEnacted
- testGateSuppression_dosingNotAllowed_noDoseEnacted

These complement the gate-logic UNIT tests in Phase 2 (which used a
RecordingPumpManager mock). The unit tests prove the gate logic is
right in isolation; these integration tests prove the gates actually
prevent the dose from reaching the real pod through the full production
plumbing (real OmniBLEPumpManager + emulated pod, real WatchAlgorithmKit
driver, real LoopAlgorithmRunner).

Each test takes ~10-30s (pod pairing + algorithm iteration + assertion);
the full WatchAlgorithmEndToEndTests suite is ~1-2 min total.

Extracted a shared GateTestSetup helper + assertSuppressedEndToEnd
helper to keep the 3 sub-tests focused on their differentiating gate
parameter.

threecee-claude
threecee pushed a commit to threecee/OmniBLE that referenced this pull request May 2, 2026
…oopKit#5)

Adds claimedOwner: HandoffOwner? field to PhoneWatchHeartbeat. Each
side will populate it from local handoffState.currentOwner (Loop-side
wiring lands in Phase 3). On reception, the watch detects split-brain
when its local state says it's the owner AND the inbound heartbeat
says counterpart claims ownership too. Phone-wins arbitration: watch
silently demotes itself.

Bumps PhoneWatchProtocol.currentVersion 2 -> 3. Backward-compatible:
- Old (v2) sender + new (v3) receiver: decodes claimedOwner as nil
  -> no split-brain detection on that heartbeat (degrades silently).
- New (v3) sender + old (v2) receiver: ignores unknown field via
  Swift JSONDecoder default behavior.

Updates 3 tests in PhoneWatchMessageTests (testCurrentVersionIsTwo ->
IsThree; testAcceptsLowerOrCurrentProtocolVersion now accepts v3;
testRejectsHigherProtocolVersion now rejects v4 instead of v3).

Adds 2 new Codable round-trip tests:
- claimedOwner field survives encode -> decode
- v2-shaped JSON decodes with claimedOwner = nil

threecee-claude
threecee pushed a commit to threecee/OmniBLE that referenced this pull request May 4, 2026
Deduplicates the iOS<->watch bootstrap chain that LoopAppManager and
ExtensionDelegate hand-built (~54 LOC of duplicated wiring per
/simplify quality LoopKit#5). Single static factory constructs all 6 stack
components in dependency order, parameterized by HandoffRole + closure
injection points for the role-conditional behavior:

  - pumpManager: OmniBLEPodOwner? (phone supplies, watch nil)
  - settingsSyncProvider: phone-only (settings sync is phone -> watch)
  - onSettingsSyncReceived / onSnapshotReceived: watch-only cache writes
  - makeWatchSidePumpManager: watch-only lazy pump-manager construction

Factory is intentionally small: it constructs and wires components but
does NOT call start(), publish .shared singletons, or install host-
specific peripherals (HealthKit, G7, AlgorithmStateSnapshotEmitter,
ExtendedRuntimeCoordinator). Those stay with the host bootstrap so the
factory can be exercised in unit tests without polluting global state.

Tests: assemble_phone_buildsStack, assemble_watch_buildsStack,
assemble_isReentrant_returnsDistinctInstances. All green.

threecee-claude
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants