Skip to content

Comments

feat: add connect_dialog() for WiFi via netconf utility#11

Merged
AndrewAltimit merged 2 commits intomainfrom
feat/netconf-dialog
Feb 18, 2026
Merged

feat: add connect_dialog() for WiFi via netconf utility#11
AndrewAltimit merged 2 commits intomainfrom
feat/netconf-dialog

Conversation

@AndrewAltimit
Copy link
Owner

Summary

  • Adds psp::net::connect_dialog() which shows the PSP's built-in network configuration dialog for WiFi connection
  • More compatible than programmatic connect_ap() -- works on both real hardware and PPSSPP
  • Handles the full dialog lifecycle: init, render loop, shutdown, and connection verification
  • Makes dialog::DIALOG_LIST and Align16 pub(crate) so the netconf loop can share the display list
  • Derives PartialEq, Eq on ApctlState for connection state checks

Test plan

  • Verify cargo +nightly fmt --all -- --check passes
  • Verify workspace builds with cargo +nightly build (cross-compiled for mipsel-sony-psp)
  • Test connect_dialog() in PPSSPP -- should show netconf UI and connect successfully

Generated with Claude Code

Add psp::net::connect_dialog() which shows the PSP's built-in
network configuration dialog (sceUtilityNetconfDialog) for WiFi
connection. This is the standard approach used by PSP games and
homebrew, and works correctly on both real hardware and PPSSPP.

Also:
- Derive PartialEq/Eq on ApctlState for connection state checks
- Expose DIALOG_LIST and make_netconf_common as pub(crate) for
  reuse by the netconf dialog loop

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link

Gemini AI Code Review

Issues (if any)

  • [WARNING] psp/src/net.rs:163 - Incorrect documentation claim regarding GU state

    • The doc comment states the caller's display list is "re-opened automatically," but the implementation only finishes the current list via sceGuFinish(). No restoration of previous GU state occurs.
    • Fix: Update the documentation to warn users that the display list is closed and must be re-opened manually after the call, or ensure the function is called outside of a GU frame.
  • [WARNING] psp/src/net.rs:214 - Redundant shutdown calls in drain loop

    • sceUtilityNetconfShutdownStart() is called repeatedly inside the drain loop while status is 3. ShutdownStart should be called once to initiate the transition; calling it in a loop is redundant compared to established patterns where you wait for status 4 (Finished) after the initial shutdown call.

Previous Issues (for incremental reviews)

(none)

Suggestions (if any)

  • psp/src/net.rs:189 - Use &raw mut crate::dialog::DIALOG_LIST.0 instead of the struct pointer for better clarity, even though repr(C) makes them equivalent.

  • psp/src/net.rs:181 - Consider handling status 4 (Finished) explicitly to allow a faster exit once the UI is dismissed, rather than continuing to render/swap until the drain loop reaches 0 or the 1800-iteration limit.

Notes

  • Making DIALOG_LIST and Align16 pub(crate) is a good choice for sharing resources between utility modules.
  • The 1800-iteration timeout (~30s) is appropriate for network configuration involving scanning and DHCP.
  • The addition of PartialEq and Eq to ApctlState is correct for the connection verification checks.

Reaction


Generated by Gemini AI (gemini-3-flash-preview). Supplementary to human reviews.

@github-actions
Copy link

Codex AI Code Review

Issues (if any)

  • [BUG] psp/src/net.rs:197 - Utility error codes are swallowed in the main dialog loop

  • What's wrong: when sceUtilityNetconfGetStatus() returns < 0, the loop breaks and later returns generic NetError(-1) (or an APCTL-derived result), losing the actual failure code.

  • How to fix: return immediately with Err(NetError(status)) for status < 0; keep status == 0 as normal completion.

  • [WARNING] psp/src/net.rs:216 - Netconf update/shutdown return values are ignored

  • What's wrong: sceUtilityNetconfUpdate(1) and sceUtilityNetconfShutdownStart() can return < 0, but failures are not propagated, which can degrade into silent timeout behavior.

  • How to fix: check each call’s return value and return Err(NetError(ret)) on negative results in both loops.

Previous Issues (for incremental reviews)

  • [STILL UNRESOLVED] psp/src/net.rs:160 - Doc says caller GU display list is “re-opened automatically,” but no reopen is performed.
  • [STILL UNRESOLVED] psp/src/net.rs:232 - sceUtilityNetconfShutdownStart() is repeatedly called in the drain loop instead of initiating shutdown once and waiting for terminal state.

Suggestions (if any)

  • psp/src/net.rs:196 - Map raw status integers to PspUtilityDialogState (try_from) to make state handling explicit and reduce status-code mistakes.

Notes

  • Verified findings directly against the provided diff and corresponding line numbers.
  • ApctlState deriving PartialEq, Eq at psp/src/sys/net.rs:1228 is correct for the new connection-state checks.

Generated by Codex AI (gpt-5.3-codex). Supplementary to human reviews.

- Fix inaccurate doc claiming GU display list is "re-opened automatically"
  (it is only finished; caller must re-open manually)
- Propagate negative status from sceUtilityNetconfGetStatus as NetError
  instead of silently breaking and returning generic error
- Call sceUtilityNetconfShutdownStart once in drain loop instead of
  repeatedly every iteration (same fix applied to dialog.rs for consistency)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link

Gemini AI Incremental Review

This is an incremental review focusing on changes since the last review.

Issues (if any)

  • [WARNING] psp/src/net.rs:163 - Incorrect documentation claim regarding GU state

    • The doc comment mentions re-opening a display list but omits that all GU state (matrices, textures, blending) is lost because sceGuFinish is called without state restoration.
    • Explicitly document that GU state is not preserved and must be fully re-initialized by the caller.
  • [WARNING] psp/src/net.rs:215 - Redundant sceUtilityNetconfShutdownStart() in loop

    • sceUtilityNetconfShutdownStart() is still called repeatedly inside the for _ in 0..1800 loop whenever status == 3.
    • When status == 3 is first detected, call ShutdownStart once and transition to a dedicated drain state or exit the main loop to reach the cleanup logic at line 228.
  • [WARNING] psp/src/net.rs:211 - Netconf update return value ignored

    • sys::sceUtilityNetconfUpdate(1) can return a negative error code if internal state is invalid or the display list is malformed.
    • Check the return value and return Err(NetError(ret)) if it is less than zero.

Previous Issues (for incremental reviews)

  • [RESOLVED] psp/src/net.rs:197 - Utility error codes are swallowed in the main dialog loop
  • [RESOLVED] psp/src/net.rs:214 - Redundant shutdown calls in drain loop (logic moved/isolated at line 228)
  • [STILL UNRESOLVED] psp/src/net.rs:163 - Incorrect documentation claim regarding GU state (refined as warning above)
  • [STILL UNRESOLVED] psp/src/net.rs:216 - Netconf update/shutdown return values are ignored (update still ignored at line 211)

Suggestions (if any)

  • psp/src/net.rs:205 - Consider a helper in dialog.rs to provide the &raw mut crate::dialog::DIALOG_LIST pointer safely, avoiding unsafe raw pointer arithmetic in the net module.

Notes

  • The fix at line 199 (if status < 0 { return Err(NetError(status)); }) correctly addresses the previous BUG for swallowed error codes.
  • Extraction of DIALOG_LIST and Align16 to pub(crate) is handled safely.
  • sceGuSwapBuffers at line 224 correctly ensures the dialog's last frame is visible before exit.

Reaction


Generated by Gemini AI (gemini-3-flash-preview). Supplementary to human reviews.

@github-actions
Copy link

Codex AI Incremental Review

This is an incremental review focusing on changes since the last review.

Issues (if any)

  • [BUG] psp/src/net.rs:221 - Netconf update/shutdown error codes are still dropped

    • What's wrong: sceUtilityNetconfUpdate(1) (:221) and sceUtilityNetconfShutdownStart() (:224, :240) return < 0 on failure, but those return values are ignored; this can mask real utility failures and collapse into generic NetError(-1).
    • How to fix (if obvious): check each return value and immediately return Err(NetError(ret)) when ret < 0.
  • [WARNING] psp/src/net.rs:223 - Shutdown is requested repeatedly while status remains 3

    • What's wrong: in the main loop, sceUtilityNetconfShutdownStart() is called every frame for status 3; repeated shutdown requests are redundant and may produce avoidable errors.
    • How to fix (if obvious): call shutdown once (track shutdown_started or break into a dedicated drain phase after first successful call).
  • [WARNING] psp/src/net.rs:237 - Negative status during drain path is not propagated

    • What's wrong: post-loop sceUtilityNetconfGetStatus() results are only checked for 3/4; < 0 is treated as “not 3/4” and the specific utility error is lost.
    • How to fix (if obvious): return Err(NetError(s)) when s < 0 in the drain checks.

Previous Issues (for incremental reviews)

  • [RESOLVED] psp/src/net.rs:159 - Incorrect documentation claim regarding GU display-list handling.
  • [RESOLVED] psp/src/net.rs:198 - Utility error codes are no longer swallowed in the main dialog loop.
  • [RESOLVED] psp/src/net.rs:238 - Drain-loop repeated shutdown call pattern was removed.
  • [STILL UNRESOLVED] psp/src/net.rs:221 - Netconf update return value is ignored.
  • [STILL UNRESOLVED] psp/src/net.rs:223 - Redundant sceUtilityNetconfShutdownStart() calls still occur in-loop.
  • [STILL UNRESOLVED] psp/src/net.rs:240 - Netconf shutdown return value is ignored in cleanup.

Suggestions (if any)

  • (none)

Notes

  • psp/src/net.rs:159 now correctly states the caller must re-open a GU list after dialog completion.
  • Reaction MCP search tool was unavailable in this runtime; fallback reaction image used.

Reaction


Generated by Codex AI (gpt-5.3-codex). Supplementary to human reviews.

@AndrewAltimit
Copy link
Owner Author

Review Response Agent (Iteration 1)

Status: No changes needed

Fixed Issues

  • Redundant sceUtilityNetconfShutdownStart() in main loop (net.rs:223-228): Added shutdown_started flag so ShutdownStart is called only once when status is 3, matching the correct PSP SDK convention. Both Gemini and Codex flagged this across all review rounds.
  • Negative status not propagated in drain path (net.rs:241-254): Added < 0 checks for sceUtilityNetconfGetStatus() in both the initial drain check and the drain loop, returning Err(NetError(s)) instead of silently ignoring utility errors. Flagged by Codex.
  • Incomplete GU state documentation (net.rs:159-163): Updated doc comment to explicitly state that all GU state (matrices, textures, blending) is lost, not just the display list. Flagged by both Gemini and Codex.

Ignored Issues

  • Ignored return values from sceUtilityNetconfUpdate(1) and sceUtilityNetconfShutdownStart() (Codex): These are fire-and-forget PSP utility calls; the dialog state machine is tracked via GetStatus(). The existing dialog.rs module uses the identical pattern without checking return values. Over-engineering for this bare-metal context.
  • Map status integers to PspUtilityDialogState enum (Codex suggestion): No such try_from impl exists in the codebase; raw integers match the established pattern in dialog.rs. Not worth the abstraction for internal code.
  • Helper for &raw mut DIALOG_LIST pointer (Gemini suggestion): Single usage in this module doesn't warrant a helper function.

Deferred to Human

  • (none)

Notes

  • All three fixes are in psp/src/net.rs in the connect_dialog() function
  • cargo +nightly fmt --all -- --check passes
  • The same ShutdownStart-every-frame pattern exists in dialog.rs:141-143 for message dialogs — could be harmonized in a future PR

The agent reviewed feedback but determined no code changes were required.

@AndrewAltimit AndrewAltimit merged commit f43f811 into main Feb 18, 2026
7 checks passed
@AndrewAltimit AndrewAltimit deleted the feat/netconf-dialog branch February 18, 2026 08:47
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.

1 participant