Skip to content

Commit 33b1268

Browse files
Support setting channel for SoftAP (#2695)
Fixes #2694
1 parent def00ba commit 33b1268

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

libraries/WiFi/src/WiFiClass.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,23 +160,26 @@ uint8_t WiFiClass::beginAP(const char *ssid) {
160160
}
161161

162162
uint8_t WiFiClass::beginAP(const char *ssid, uint8_t channel) {
163-
(void) channel;
164-
return beginAP(ssid, nullptr);
163+
return beginAP(ssid, nullptr, channel);
165164
}
166165

167-
uint8_t WiFiClass::beginAP(const char *ssid, const char* passphrase, uint8_t channel) {
168-
(void) channel;
169-
return beginAP(ssid, passphrase);
166+
uint8_t WiFiClass::beginAP(const char *ssid, const char* passphrase) {
167+
return beginAP(ssid, passphrase, 0);
170168
}
171169

172-
uint8_t WiFiClass::beginAP(const char *ssid, const char* passphrase) {
170+
uint8_t WiFiClass::beginAP(const char *ssid, const char* passphrase, uint8_t channel) {
173171
end();
174172

175173
_ssid = ssid;
176174
_password = passphrase;
177175
_wifi.setAP();
178176
_wifi.setSSID(_ssid.c_str());
179177
_wifi.setPassword(passphrase);
178+
#if defined(PICO_CYW43_SUPPORTED)
179+
if (channel > 0) {
180+
cyw43_wifi_ap_set_channel(&cyw43_state, channel);
181+
}
182+
#endif
180183
_wifi.setTimeout(_timeout);
181184
_apMode = true;
182185
IPAddress gw = _wifi.gatewayIP();

0 commit comments

Comments
 (0)