Skip to content

Commit 5742a12

Browse files
committed
input validation consistent with esp-idf is moved to common-hal
1 parent 7884e73 commit 5742a12

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

ports/espressif/common-hal/wifi/Radio.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,12 @@ void common_hal_wifi_radio_start_ap(wifi_radio_obj_t *self, uint8_t *ssid, size_
213213
config->ap.password[password_len] = 0;
214214
config->ap.channel = channel;
215215
config->ap.authmode = authmode;
216+
217+
if (max_connections < 0 || max_connections > 10) {
218+
mp_raise_ValueError(translate("max_connections must be between 0 and 10"));
219+
}
216220
config->ap.max_connection = max_connections;
221+
217222
esp_wifi_set_config(WIFI_IF_AP, config);
218223
}
219224

shared-bindings/wifi/Radio.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_stop_station_obj, wifi_radio_stop_station);
243243
//| otherwise ``WPA_WPA2_PSK``.
244244
//|
245245
//| If ``max_connections`` is given, the access point will allow up to
246-
//| that number of stations to connect. Default is 4. Maximum is 10."""
246+
//| that number of stations to connect."""
247247
//| ...
248248
//|
249249
STATIC mp_obj_t wifi_radio_start_ap(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
@@ -288,10 +288,6 @@ STATIC mp_obj_t wifi_radio_start_ap(size_t n_args, const mp_obj_t *pos_args, mp_
288288
authmode = 1;
289289
}
290290

291-
if (args[ARG_max_connections].u_int < 0 || args[ARG_max_connections].u_int > 10) {
292-
mp_raise_ValueError(translate("max_connections must be between 0 and 10"));
293-
}
294-
295291
common_hal_wifi_radio_start_ap(self, ssid.buf, ssid.len, password.buf, password.len, args[ARG_channel].u_int, authmode, args[ARG_max_connections].u_int);
296292
return mp_const_none;
297293
}

0 commit comments

Comments
 (0)