Skip to content
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

WiFi.setTxPower() always return +19.5dBm #9858

Closed
1 task done
enjoyneering opened this issue Jun 13, 2024 · 3 comments · Fixed by #9862
Closed
1 task done

WiFi.setTxPower() always return +19.5dBm #9858

enjoyneering opened this issue Jun 13, 2024 · 3 comments · Fixed by #9862
Labels
Status: Awaiting triage Issue is waiting for triage

Comments

@enjoyneering
Copy link

Board

ESP32 Dev Module

Device Description

plain module

Hardware Configuration

plain module

Version

v3.0.1

IDE Name

Arduino IDE

Operating System

Windows 10

Flash frequency

80MHz

PSRAM enabled

no

Upload speed

115200

Description

WiFi.setTxPower() always return +19.5dBm in AP or STA mode

I think there is a typo in the setTxPower() and getTxPower().

Sketch

//in setTxPower() and getTxPower() instead of &&

if (!WiFi.STA.started() && !WiFi.AP.started()) {  //&& is wrong
    log_w("Neither AP or STA has been started");

//should be ||
if (!WiFi.STA.started() || !WiFi.AP.started()) { //|| is correct
    log_w("Neither AP or STA has been started");

Debug Message

return +19.5dBm

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@enjoyneering enjoyneering added the Status: Awaiting triage Issue is waiting for triage label Jun 13, 2024
@JAndrassy
Copy link
Contributor

JAndrassy commented Jun 14, 2024

"Neither AP or STA has been started" is !(WiFi.STA.started() || WiFi.AP.started())
which in boolean algebra is same as!WiFi.STA.started() && !WiFi.AP.started()

@me-no-dev
Copy link
Member

The following code resulted in TX Power: 11.0dBm:

  WiFi.STA.begin();
  if(!WiFi.STA.waitStatusBits(ESP_NETIF_STARTED_BIT, 10000)){
    Serial.println("Failed to start WiFi!");
  }
  WiFi.setTxPower(WIFI_POWER_11dBm);
  int pwr = WiFi.getTxPower();
  Serial.printf("TX Power: %.1fdBm\n", pwr * 0.25);
  WiFi.STA.connect(SSID, PASSWORD);

@enjoyneering
Copy link
Author

Thank you me-no-dev. My bad. It looks like there is already the pull request for this issue. I close mine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting triage Issue is waiting for triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants