WiFi.h for the ESP32 has many #include statements
#include "WiFiGeneric.h"
If you look in that file you will see this enum for wifi_power_t
typedef enum {
WIFI_POWER_19_5dBm = 78,// 19.5dBm
WIFI_POWER_19dBm = 76,// 19dBm
WIFI_POWER_18_5dBm = 74,// 18.5dBm
WIFI_POWER_17dBm = 68,// 17dBm
WIFI_POWER_15dBm = 60,// 15dBm
WIFI_POWER_13dBm = 52,// 13dBm
WIFI_POWER_11dBm = 44,// 11dBm
WIFI_POWER_8_5dBm = 34,// 8.5dBm
WIFI_POWER_7dBm = 28,// 7dBm
WIFI_POWER_5dBm = 20,// 5dBm
WIFI_POWER_2dBm = 8,// 2dBm
WIFI_POWER_MINUS_1dBm = -4// -1dBm
} wifi_power_t;
If you substitute one of the enum values in the .setTxPower( ) the code will compile without error.
#include <SPI.h>
#include <WiFi.h>
char ssid[] = "SSID1";
char pass[] = "PASS1";
void setup()
{
Serial.begin(115200);
WiFi.mode(WIFI_STA);
delay(100);
WiFi.begin(ssid, pass);
delay(5000);
}
void loop()
{
delay(1000);
if (WiFi.status() != WL_CONNECTED)
{
WiFi.disconnect();
delay(1000);
WiFi.begin(ssid, pass);
delay(5000); // Allowing connection to be established, before reconnecting
}
else
{
//WiFi.setTxPower(70);
WiFi.setTxPower(WIFI_POWER_18_5dBm);
//WIFI_POWER_18_5dBm = 74
int a = WiFi.getTxPower();
Serial.print("TX power:");
Serial.println(a);
delay(2000);
}
}
I am using the 2.0.0 alpha1 development release core through the board manager which includes the S2 and S3 in the master.