Skip to content

omamobile-shell 0.2.33: NFC polls only while the screen is lit - #99

Merged
derekross merged 8 commits into
derekross:mainfrom
W4HO-ham:shell-nfc-screen-off
Oct 31, 2026
Merged

derekross merged 8 commits into
derekross:mainfrom
W4HO-ham:shell-nfc-screen-off

Conversation

@W4HO-ham

Copy link
Copy Markdown
Contributor

A poll loop is the NFC radio searching for cards. On the Pixel 9a it costs about 60 mA awake with the screen off: 252 mA with NFC off against 315 mA with it on, in a cable-out drain test today. Stock Android polls only while the screen is on.

omamobile-nfc-open now stops neard's poll loop once every display connector has been DPMS off for 4 s, and starts it again when the screen lights. If the NFC switch is off, it stays off. It reads the connectors' dpms in sysfs, so it needs no session access.

Tested on the 9a: no controller interrupts in 10 s with the screen off, 102 in the first 6 s after it came on, and the journal shows the stop and the restart. The package tests (217) and pr-check pass. The 7 Pro should behave the same, since it uses the same neard path.

A poll loop is the NFC radio searching for cards. On the Pixel 9a it costs
about 60 mA with the screen off (252 mA against 315 mA, awake, 10-27),
and stock Android polls only while the screen is on. omamobile-nfc-open
now stops neard's poll loop once every display connector has been DPMS
off for 4 s, and starts it again when the screen lights, unless the NFC
switch is off. Tested on the 9a: no controller interrupts with the screen
off, polling again within 2 s of it lighting.
@derekross

Copy link
Copy Markdown
Owner

Thanks, @W4HO-ham. Stopping the poll loop with the screen off is what stock does, 60 mA is a lot to spend on searching for cards nobody can tap, and reading DPMS from sysfs keeps the service out of the session. I'd like this on the 7 Pro too.

That also means it changes the reference phone: omamobile-nfc-open runs at every boot there, and our display driver updates the connector's dpms, so this will stop the 7 Pro's polling whenever the screen is off. Under the rule for shared code, I'll run it on my phone before it merges. I'm planning an NFC-tile check for kernel #71 anyway, so it fits in the same session.

One change first. The stop only happens on the lit-to-dark transition, so anything that starts polling again while the screen is dark wins until the next screen-on/off cycle. I can see three ways that happens:

  1. Your own unblock path: restart_neard() schedules start_polling at +2 s, which keeps retrying every 2 s while neard has no adapter, and the stop is a single shot at +4 s. A slow neard starts polling after the stop, and it stays on. (It's start_polling here that starts the loop, not neard by itself, so the comment there needs fixing too.)
  2. The 9a's sleep hook restarts neard's poll loop after every systemd sleep, so after an RTC or notification wake with the screen dark, polling resumes and stays on.
  3. neard restarted by systemd.

Making it level-triggered fixes all three: while the screen has been dark for 4 s, stop whenever an adapter reports Polling. Or, more simply, have start_polling skip StartPollLoop (but still power the adapter) when the screen is dark, and drop the extra 4 s timeout. A small test of screen_lit() against a temporary sysfs tree would also be welcome: connected and disconnected, On and Off, and no connectors at all.

It doesn't conflict with the tile: when NFC is switched off, screen-on doesn't start polling, as it should.

…ays dark

The stop was a single shot on the lit-to-dark transition, so anything that started polling afterwards kept it on until the next screen cycle: the unblock path's start_polling retries, the 9a's sleep hook after a wake, or neard restarted by systemd. Now every 2 s check stops any poll loop once the screen has been dark for 4 s, and start_polling powers the adapter but leaves the loop off while it's dark. The one-shot stop after an unblock is gone. test/nfc-screen.py checks screen_lit() against temporary sysfs trees.
@derekross

Copy link
Copy Markdown
Owner

Thanks, @W4HO-ham, the level-triggered stop is exactly right: every tick now stops a poll loop that anything started while the screen is dark, start_polling powers the adapter but leaves the loop off, and the one-shot stop and its comment are gone. The screen_lit() test covers the cases I asked for, and it passes here.

One more thing, which I should have caught last time. start_polling sets Powered without a try (lines 101-104), and since this PR it runs from follow_screen, a GLib timeout callback. When a PyGObject timeout callback raises, GLib removes the timer: I checked with a ten-line script, and a callback that raised once was never called again. So if a power-on fails at screen-on (neard restarting between GetManagedObjects and the Set, or NFC switched off within the same 2 s tick, before follow_rfkill has seen it), the service stops following the screen until it's restarted, and polling stays wherever it was. Please wrap that Set in try/except GLib.Error and log it, the way set_powered does.

Has the new head run on the 9a? A line from a dark RTC wake (the sleep-hook case) showing "screen off: polling stopped" within a tick would be enough.

The plan for the 7 Pro is the same as before: I'll run it on my phone before it merges, and I'll add one step for the new code: systemctl restart neard with the screen dark, then check that polling stays off.

#115 and #117 are both ready: everything I asked for there is done. They merge right after this one, in order.

derekross added a commit that referenced this pull request Oct 28, 2026
…ry work

Open PRs hold device-cheetah 0.1.35 (#102) and omamobile-shell 0.2.33
to 0.2.36 (#99, #115, #117, #124); this branch takes the next free ones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
derekross added a commit that referenced this pull request Oct 28, 2026
0.2.33 to 0.2.37 are held by #99, #115, #117, #124 and the low-battery
branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
derekross added a commit that referenced this pull request Oct 28, 2026
…ry work

Open PRs hold device-cheetah 0.1.35 (#102) and omamobile-shell 0.2.33
to 0.2.36 (#99, #115, #117, #124); this branch takes the next free ones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… not raised

start_polling runs from follow_screen's GLib timeout since the screen-off
change, and a timeout callback that raises is removed by GLib for good.
Wrap the adapter's Powered Set in try/except GLib.Error, log it and retry
on the next tick, as set_powered does.
@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Pushed b24a2b3: the `Powered` Set in `start_polling` is now in `try/except GLib.Error`. It logs the error and returns `True`, so the next tick retries and the timer stays alive.

I ran that head on the 9a (omamobile-shell 0.2.36 with this branch's `omamobile-nfc-open` copied over it), with the screen dark (DPMS off, connector `dpms` = Off):

  • I started a poll loop by hand while it was dark. The stop came 0.3 s later: `13:16:53.709 omamobile-nfc-open: screen off: polling stopped on /org/neard/nfc0`.
  • For the sleep-hook case I did a dark RTC wake through `systemctl suspend` (RTC alarm 25 s), with the hook's state file set so `post` restarts the loop. The hook ran, but its `StartPollLoop` failed: right after resume the controller answered `nxp-nci_i2c 25-0008: NFC: Error -6 on I2C send`. So there was no loop for the script to stop, and `Polling` stayed false. That I2C error after resume is the 9a's own problem, and I'll chase it separately.
  • One thing for your neard-restart step: on the 9a, after `systemctl restart neard` the kernel device still counted as polling, and `StartPollLoop` answered EBUSY ("Device or resource busy") until I powered the adapter off and on. The script logged "could not start polling: … busy" and carried on, without raising.

@derekross

Copy link
Copy Markdown
Owner

Thanks, @W4HO-ham. The try/except is in, and the timer now survives a failed power-on: I fed follow_screen a fake neard whose Set fails once at screen-on, and the callback kept returning True and kept running. The 9a run is useful too. A poll loop you started by hand while the screen was dark, stopped 0.3 s later, is the same thing the sleep hook does from the script's side, so I'm happy for that to stand in for the RTC-wake line. The I2C -6 after resume deserves its own issue when you get to it.

One small thing before it merges. The new comment and your reply say the next tick retries the power-on, but that's only true for the timer restart_neard() sets up. At screen-on, follow_screen sets screen["lit"] = True, calls start_polling once and ignores what it returns. On the next tick the screen is already marked lit, so nothing calls start_polling again, and polling stays off until the screen goes dark and lights again. In the same fake-neard run, the adapter was still unpowered three ticks later.

There's also a smaller side effect of the new return True. If NFC is switched off in the couple of seconds between restart_neard() and a successful power-on, the kernel refuses the power-on, so that timer now logs a Powered=True error every 2 s until NFC is switched back on. Before this change the exception ended the timer.

Something like this fixes both. The package tests pass with it, and with the fake neard the adapter powers up and starts polling on the next tick:

 def start_polling(bus):
     """Power the first adapter and start a poll loop (neard's ConstantPoll
-    keeps it going after each tag)."""
+    keeps it going after each tag). True means "try again": neard isn't
+    answering, has no adapter yet, or refused the power-on."""
+    if rfkill["blocked"]:
+        return False  # switched off meanwhile; the next unblock restarts neard
     try:
@@
 rfkill = {"blocked": None}
-screen = {"lit": True, "dark_for": 0}
+screen = {"lit": True, "dark_for": 0, "start": False}
@@
         screen["dark_for"] = 0
         if not screen["lit"]:
             screen["lit"] = True
-            if not rfkill["blocked"]:
+            screen["start"] = not rfkill["blocked"]
+            if screen["start"]:
                 log("screen on: polling again")
-                start_polling(bus)
+        if screen["start"]:
+            screen["start"] = start_polling(bus)
         return True

A failed StartPollLoop still isn't retried with this, on purpose: on your 9a the EBUSY lasted until the adapter was power-cycled, so retrying every 2 s would only fill the journal. If you'd rather keep the code as it is, please just reword the comment so it doesn't promise a retry.

On my side, I'll run this head on the Pixel 7 Pro before it merges, as planned. Because of what you saw after systemctl restart neard on the 9a, I'll check the NFC controller's interrupt count as well as neard's Polling property, both with the screen dark and after a neard restart. I'll post the results here.

Merge order stays the same: this one, then #115 and #117 with their own commits cherry-picked onto main, as we discussed on those PRs.

derekross added a commit that referenced this pull request Oct 28, 2026
L-279 to L-293: the 9a's slot B hold and what made devinfo writable
(#125), per-device flags checked by building both command lines
(#101), env defaults in the shared build library and CI waiting for
approval (#79), GLib retry paths and radio stops checked at the
controller (#99), silent re-pushes and stacks with several tops (the
tegu stack), and two of our own: merge only after every check has
finished (#126), and an empty diff is checked for empty inputs
(kernel #123).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
derekross added a commit that referenced this pull request Oct 28, 2026
…wenty-sixth rounds (#127)

* docs/review: 19 lessons and 3 corrections from the twenty-fifth round

The confirmed candidates from round 25 (L-260 to L-278): the 9a slot B
marking as a devinfo question, cross-repository links, squash-merged
stacks and version files, stale hand-built prebuilts, and before-merge
Pixel 7 Pro runs on omamobile-int. C-16 to C-18 correct our own earlier
comments on kernel #98, kernel #80 and #74; L-241 is corrected in place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs/review: 15 lessons from the twenty-sixth round

L-279 to L-293: the 9a's slot B hold and what made devinfo writable
(#125), per-device flags checked by building both command lines
(#101), env defaults in the shared build library and CI waiting for
approval (#79), GLib retry paths and radio stops checked at the
controller (#99), silent re-pushes and stacks with several tops (the
tegu stack), and two of our own: merge only after every check has
finished (#126), and an empty diff is checked for empty inputs
(kernel #123).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Applied your change as 56d6005: screen-on keeps calling start_polling on each tick until it powers the adapter (or NFC is switched off), and start_polling returns False at once when rfkill blocks it, so a timer no longer logs a refused power-on every 2 s. A failed StartPollLoop still isn't retried. Package tests pass. I'll file the I2C -6 after resume as its own issue. Today's lead: the controller loses its NCI state across s2idle, and powering the adapter off before the sleep and on after brings it back.

@derekross

Copy link
Copy Markdown
Owner

Thanks, 56d6005 is exactly the change I asked for, line for line. I haven't forgotten it: what's left is my run on the 7 Pro, and the phone is off my desk at the moment. I'll do it as the first step of the next shell session, together with #124 and the other shell PRs behind this one, and merge #99 right after it passes.

# Conflicts:
#	packages/omamobile-shell/version
@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Merged tonight's main and took the version to 0.2.48 (main is 0.2.45; my #183 holds 0.2.46 and #197 0.2.47). Nothing dropped: the screen-aware poll loop isn't in main in any form. pr-check passes and the package suite passes; the one failure I saw was test/owl-idle's timing assertion flipping while this machine was busy, and it passes four times in a row on this branch and three on plain main, so it isn't from here.

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

The failing Tests job here is the paused-tick check in test/owl-idle, not anything in this branch: it is false for one second in every ten by construction. #207 fixes it, and this should go green once that is in.

derekross and others added 2 commits October 31, 2026 11:12
…is lit

Restores this pull request's change: the merge at b3ceaf1 resolved to
main's tree and dropped it. 0.2.46 and 0.2.47 are held by derekross#183 and derekross#197.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@derekross

Copy link
Copy Markdown
Owner

Heads-up on the last merge: b3ceaf1 resolved to main's tree, so the branch ended up identical to main and the screen-aware poll loop was gone (the diff against main was empty). I've pushed 574c76e on top of your head, a fast-forward with nothing rewritten. It puts back omamobile-nfc-open, test/nfc-screen.py and the test lines exactly as in 56d6005, at 0.2.48 as you planned, and merges today's main, including #207, so the owl-idle flake is gone.

Tested on the 7 Pro last night with this exact change: with the screen off for 4 s, neard's poll loop stops and the adapter stays powered; it starts again when the screen comes on, and rfkill block/unblock still behaves. I'll merge once CI is green.

@derekross
derekross merged commit f1859b7 into derekross:main Oct 31, 2026
2 checks passed
derekross pushed a commit that referenced this pull request Oct 31, 2026
…is loaded (#197)

Omarchy's hyprland.lua loads the look-and-feel rules from looknfeel.lua, so the phone rules go to whichever file the loaded config actually requires; on the Pixel 7 Pro (Omarchy 4.0.6) that is still looknfeel.lua, so nothing changes there. Renumbered to 0.2.49 at merge, after #99 took 0.2.48.

Closes #197

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
derekross pushed a commit that referenced this pull request Oct 31, 2026
The home screen's OWL host answered every device and system query with
the Pixel 7 Pro's fixed values. The model and codename now come from the
device tree (model and the first compatible), with a small table for what
the device tree doesn't say about the two Pixels we run on (panel size,
top refresh rate, density); any other board reports display: null rather
than a guess. On the Pixel 7 Pro the answers are unchanged.

Rebuilt on main by the maintainer from the pull request's own three files,
since the branch carried an older #99 underneath; renumbered to 0.2.50.

Closes #115

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
derekross added a commit that referenced this pull request Oct 31, 2026
… rounds

L-348 to L-361: shared drivers judged against every int-line user (#150),
board pins against every stock user (#151), ownership flags under the
consumer's lock (#152), /chosen children and Google's panel constants
(#154), same-day notes PRs on one device (#208/#209), merge simulations for
DEVICES rows, ours included (#165), stacked PRs that merged main (#115/#117),
titles behind renumbered versions, a contributor merge that dropped the PR
(#99), smoke package lists as provenance and "owner-authorized" writes
(#200), promised fixes and named tags checked on the remote (#153/#157/#158),
and file swaps into old packages (#193). C-23 (usbc-deadman's device scope,
kernel #107) and C-24 (BNEP in a lynx-only fragment, #98).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
derekross pushed a commit that referenced this pull request Nov 2, 2026
…ing (#307)

The 9a's row after today's merges, with a NOTES entry for the evening's boots that the new cells link to.

- **Wi-Fi, testing to works.** `omamobile-device-tegu` 0.2.4 (#238) starts it at boot now, through the shared gs201 host and zuma PHY (kernel #178 on #156, both in review) and brcmfmac (kernel #56, in review), with only the extractor's firmware. The NOTES entry has the boot, and the three rebinds with Bluetooth up after #178's FLR commit. The kernel parts are still in review, and the cell says so, as the display cells did.
- **Suspend, WIP to testing.** The power key now lights the lock screen on the first press (#268, #275). Thirty attended sleeps and a day of real use with auto-sleep on all woke (SLEEP-PLAN, #284). The cell still says that three test sleeps on 10-28 to 10-30 never woke and that sleep tests stay attended. If you'd rather keep WIP until that hang is understood, I'll revert just the word.
- **Display:** the display DT is merged, and brightness, DPMS off and on and the 60/120 Hz switch now have a dated record (kernel #125's boot, which also checks the panel ID).
- **Charging, Haptics, Torch, NFC:** kernel #161, #96, #104 and #105 are merged.
- **USB net:** the rescue also handles a replug the gadget didn't see (#280).

The NOTES entry lists each boot with its release: Wi-Fi from the package, the power-key wake, the replug, storage idle (kernel #99), the panel ID (kernel #125), the RTC without the PMIC interrupt (kernel #55), and the auto-sleep day. GNSS and Modem stay as they are until the SIM test on Tuesday. Docs only; `tools/pr-check` passes, and the diff has no identifiers.

Closes #307

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
W4HO-ham added a commit to W4HO-ham/omarchy-mobile that referenced this pull request Nov 9, 2026
… 6-hour auto-sleep series clean, and derekross#100

The shell's own auto-sleep behind the lock, with the fixed kernel: the power-key wake, 30-minute and one-hour sleeps, then a series of twelve half-hour sleeps woken by the RTC, all clean, 15 wakes in the boot with no UFS error. The two scripts arm the alarms and watch from the laptop. derekross#100 adds the modem fixes the test tree had lacked; the sleep path is unchanged.
W4HO-ham added a commit to W4HO-ham/omarchy-mobile that referenced this pull request Nov 9, 2026
… 6-hour auto-sleep series clean, and derekross#100

The shell's own auto-sleep behind the lock, with the fixed kernel: the power-key wake, 30-minute and one-hour sleeps, then a series of twelve half-hour sleeps woken by the RTC, all clean, 15 wakes in the boot with no UFS error. The two scripts arm the alarms and watch from the laptop. derekross#100 adds the modem fixes the test tree had lacked; the sleep path is unchanged.
robertzas pushed a commit to robertzas/omarchy-mobile that referenced this pull request Nov 14, 2026
…ross#99)

omamobile-nfc-open stops neard's poll loop once every display connector has been off for 4 s and starts it again when the screen comes on, as stock Android does; a poll loop costs the Pixel 9a about 60 mA. The adapter stays powered, and the rfkill handling is unchanged. Tested on the Pixel 7 Pro (2026-10-30): polling stops with the screen off and resumes on wake.
robertzas pushed a commit to robertzas/omarchy-mobile that referenced this pull request Nov 14, 2026
…is loaded (derekross#197)

Omarchy's hyprland.lua loads the look-and-feel rules from looknfeel.lua, so the phone rules go to whichever file the loaded config actually requires; on the Pixel 7 Pro (Omarchy 4.0.6) that is still looknfeel.lua, so nothing changes there. Renumbered to 0.2.49 at merge, after derekross#99 took 0.2.48.

Closes derekross#197

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
robertzas pushed a commit to robertzas/omarchy-mobile that referenced this pull request Nov 14, 2026
…ross#115)

The home screen's OWL host answered every device and system query with
the Pixel 7 Pro's fixed values. The model and codename now come from the
device tree (model and the first compatible), with a small table for what
the device tree doesn't say about the two Pixels we run on (panel size,
top refresh rate, density); any other board reports display: null rather
than a guess. On the Pixel 7 Pro the answers are unchanged.

Rebuilt on main by the maintainer from the pull request's own three files,
since the branch carried an older derekross#99 underneath; renumbered to 0.2.50.

Closes derekross#115

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
robertzas pushed a commit to robertzas/omarchy-mobile that referenced this pull request Nov 14, 2026
… rounds

L-348 to L-361: shared drivers judged against every int-line user (derekross#150),
board pins against every stock user (derekross#151), ownership flags under the
consumer's lock (derekross#152), /chosen children and Google's panel constants
(derekross#154), same-day notes PRs on one device (derekross#208/derekross#209), merge simulations for
DEVICES rows, ours included (derekross#165), stacked PRs that merged main (derekross#115/derekross#117),
titles behind renumbered versions, a contributor merge that dropped the PR
(derekross#99), smoke package lists as provenance and "owner-authorized" writes
(derekross#200), promised fixes and named tags checked on the remote (derekross#153/derekross#157/derekross#158),
and file swaps into old packages (derekross#193). C-23 (usbc-deadman's device scope,
kernel derekross#107) and C-24 (BNEP in a lynx-only fragment, derekross#98).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
robertzas pushed a commit to robertzas/omarchy-mobile that referenced this pull request Nov 14, 2026
…ing (derekross#307)

The 9a's row after today's merges, with a NOTES entry for the evening's boots that the new cells link to.

- **Wi-Fi, testing to works.** `omamobile-device-tegu` 0.2.4 (derekross#238) starts it at boot now, through the shared gs201 host and zuma PHY (kernel derekross#178 on derekross#156, both in review) and brcmfmac (kernel derekross#56, in review), with only the extractor's firmware. The NOTES entry has the boot, and the three rebinds with Bluetooth up after derekross#178's FLR commit. The kernel parts are still in review, and the cell says so, as the display cells did.
- **Suspend, WIP to testing.** The power key now lights the lock screen on the first press (derekross#268, derekross#275). Thirty attended sleeps and a day of real use with auto-sleep on all woke (SLEEP-PLAN, derekross#284). The cell still says that three test sleeps on 10-28 to 10-30 never woke and that sleep tests stay attended. If you'd rather keep WIP until that hang is understood, I'll revert just the word.
- **Display:** the display DT is merged, and brightness, DPMS off and on and the 60/120 Hz switch now have a dated record (kernel derekross#125's boot, which also checks the panel ID).
- **Charging, Haptics, Torch, NFC:** kernel derekross#161, derekross#96, derekross#104 and derekross#105 are merged.
- **USB net:** the rescue also handles a replug the gadget didn't see (derekross#280).

The NOTES entry lists each boot with its release: Wi-Fi from the package, the power-key wake, the replug, storage idle (kernel derekross#99), the panel ID (kernel derekross#125), the RTC without the PMIC interrupt (kernel derekross#55), and the auto-sleep day. GNSS and Modem stay as they are until the SIM test on Tuesday. Docs only; `tools/pr-check` passes, and the diff has no identifiers.

Closes derekross#307

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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