Skip to content

Added set/get_max_tx_power for Wifi - #584

Closed
nandee95 wants to merge 1 commit into
esp-rs:masterfrom
nandee95:wifi-tx-power
Closed

Added set/get_max_tx_power for Wifi#584
nandee95 wants to merge 1 commit into
esp-rs:masterfrom
nandee95:wifi-tx-power

Conversation

@nandee95

Copy link
Copy Markdown
Contributor

Submission Checklist 📝

  • [N/A] I have updated existing examples or added new ones (if applicable).
  • I have used cargo fmt command to ensure that all changed code is formatted correctly.
  • I have used cargo clippy command to ensure that all changed code passes latest Clippy nightly lints.
  • My changes were added to the CHANGELOG.md in the proper section.

Pull Request Details 📖

  • Added set/get max_tx_power for Wifi
  • The unit is 0.25dBm, same as esp idf

Description

I needed a way to increase wifi tx power. So I added a wrapper to esp idf esp_wifi_set_max_tx_power and esp_wifi_get_max_tx_power methods.

Testing

Set the power to maximum value of 2dBm (set value 8) -> ESP32C6 was able to connect to wifi from a shorter range
Set the power to maximum value of 20dBm (set value 80) -> ESP32C6 was able to connect to wifi from a greater range

@ivmarkov ivmarkov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just change &mut self to &self in the getter and document the power param.

Comment thread src/wifi.rs Outdated
}

/// As per [`crate::sys::esp_wifi_get_max_tx_power`](crate::sys::esp_wifi_get_max_tx_power)
pub fn get_max_tx_power(&mut self) -> Result<i8, EspError> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just &self instead of &mut self.

Comment thread src/wifi.rs
esp!(unsafe { esp_wifi_set_mac(interface.into(), mac.as_ptr() as *mut _) })
}

/// As per [`crate::sys::esp_wifi_set_max_tx_power`](crate::sys::esp_wifi_set_max_tx_power)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit: shall we rather document here (and in the get method) that power is N*0.25dBm?

@ivmarkov

ivmarkov commented Sep 9, 2025

Copy link
Copy Markdown
Collaborator

Not going anywhere, closing.

@ivmarkov ivmarkov closed this Sep 9, 2025
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