Skip to content

Commit bbeaeaa

Browse files
committed
add WiFi TX power control
1 parent 8943ac4 commit bbeaeaa

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,23 @@ WiFiPhyMode_t ESP8266WiFiGenericClass::getPhyMode() {
124124
return (WiFiPhyMode_t) wifi_get_phy_mode();
125125
}
126126

127+
/**
128+
* set the output power of WiFi
129+
* @param dBm max: +20.5dBm min: 0dBm
130+
*/
131+
void ESP8266WiFiGenericClass::setOutputPower(float_t dBm) {
132+
133+
if(dBm > 20.5) {
134+
dBm = 20.5;
135+
} else if(dBm < 0) {
136+
dBm = 0;
137+
}
138+
139+
uint8_t val = (dBm*4.0f);
140+
system_phy_set_max_tpw(val);
141+
}
142+
143+
127144
/**
128145
* store WiFi config in SDK flash area
129146
* @param persistent

libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.h

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class ESP8266WiFiGenericClass {
4646
bool setPhyMode(WiFiPhyMode_t mode);
4747
WiFiPhyMode_t getPhyMode();
4848

49+
void setOutputPower(float_t dBm);
50+
4951
void persistent(bool persistent);
5052

5153
bool mode(WiFiMode_t);

0 commit comments

Comments
 (0)