Skip to content

feat(wifi): Allow STA to restart dhcp client, and auto-restart it when changing hostname #470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2025

Conversation

finger563
Copy link
Contributor

Description

  • Add espp::WifiSta::restart_dchp_client()
  • Update espp::WifiSta::set_hostname to take new optional parameter restart_dhcp = true, which will automatically call restart_dhcp_client to apply the hostname.
  • Add method to manually restart dhcp client to wifi sta menu.

Motivation and Context

Allows the hostname to be immediately used, instead of requiring a reconnection to the network.

How has this been tested?

Build and run iperf/example on QtPy ESP32S3 and test that the DHCP client gets a new IP address lease and the new hostname is applied and can be pinged from a remote computer on the network.

Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Hardware (schematic, board, system design) change
  • Software change

Checklist:

  • My change requires a change to the documentation.
  • I have added / updated the documentation related to this change via either README or WIKI

Software

  • I have added tests to cover my changes.
  • I have updated the .github/workflows/build.yml file to add my new test to the automated cloud build github action.
  • All new and existing tests passed.
  • My code follows the code style of this project.

@finger563 finger563 requested a review from Copilot July 8, 2025 16:39
@finger563 finger563 self-assigned this Jul 8, 2025
@finger563 finger563 added enhancement New feature or request cli wifi labels Jul 8, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the WiFi station component by enabling DHCP client restarts both automatically on hostname changes and manually via the CLI menu.

  • Added restart_dhcp_client() method to the WifiSta class
  • Extended set_hostname() to optionally restart DHCP for immediate hostname application
  • Updated the CLI menu to simplify the hostname message and include a restart_dhcp_client command

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
components/wifi/include/wifi_sta_menu.hpp Simplified hostname‐set message and added manual DHCP restart menu entry
components/wifi/include/wifi_sta.hpp Introduced restart_dhcp_client(), modified set_hostname() to auto‐restart DHCP when configured
Comments suppressed due to low confidence (2)

components/wifi/include/wifi_sta_menu.hpp:66

  • [nitpick] The menu output no longer informs users that they need to restart the DHCP client or reconnect to apply the hostname change. Consider updating this message to reflect the automatic DHCP restart behavior or guide users to use the new 'restart_dhcp_client' command.
            out << fmt::format("Hostname set to '{}'\n", hostname);

components/wifi/include/wifi_sta.hpp:258

  • Consider adding unit or integration tests for the new 'restart_dhcp_client' method and for the 'restart_dhcp=false' path in 'set_hostname' to ensure these code paths are properly covered.
  bool restart_dhcp_client() {

Copy link

github-actions bot commented Jul 8, 2025

✅Static analysis result - no issues found! ✅

@finger563 finger563 merged commit e544ef1 into main Jul 8, 2025
85 checks passed
@finger563 finger563 deleted the feat/wifi-dhcp-client-restart branch July 8, 2025 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli enhancement New feature or request wifi
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant