summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradzierzanowski <a.dzierzanowski1@gmail.com>2020-01-16 11:16:43 +0100
committerDamien George <damien.p.george@gmail.com>2020-01-22 16:43:25 +1100
commita55c17dc69ac43cd41e7efe603e20298a5513b06 (patch)
treeb7437855b8b87680748b95c9ac1632fa0e82fd9a
parent59746ac14a7e639b8abd50fe626549e115c19c68 (diff)
esp32/modnetwork: Add max_clients kw-arg to WLAN.config for AP setting.
This allows the user to configure the maximum number of clients that are connected to the access point. Resolves #5125.
-rw-r--r--docs/esp32/quickref.rst1
-rw-r--r--ports/esp32/modnetwork.c9
2 files changed, 10 insertions, 0 deletions
diff --git a/docs/esp32/quickref.rst b/docs/esp32/quickref.rst
index c58f4aa76..8861ca4ac 100644
--- a/docs/esp32/quickref.rst
+++ b/docs/esp32/quickref.rst
@@ -82,6 +82,7 @@ The :mod:`network` module::
ap = network.WLAN(network.AP_IF) # create access-point interface
ap.config(essid='ESP-AP') # set the ESSID of the access point
+ ap.config(max_clients=10) # set how many clients can connect to the network
ap.active(True) # activate the interface
A useful function for connecting to your local WiFi network is::
diff --git a/ports/esp32/modnetwork.c b/ports/esp32/modnetwork.c
index ba967b8cb..06aa1c4b1 100644
--- a/ports/esp32/modnetwork.c
+++ b/ports/esp32/modnetwork.c
@@ -619,6 +619,11 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
ESP_EXCEPTIONS(tcpip_adapter_set_hostname(self->if_id, s));
break;
}
+ case QS(MP_QSTR_max_clients): {
+ req_if = WIFI_IF_AP;
+ cfg.ap.max_connection = mp_obj_get_int(kwargs->table[i].value);
+ break;
+ }
default:
goto unknown;
}
@@ -693,6 +698,10 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
val = mp_obj_new_str(s, strlen(s));
break;
}
+ case QS(MP_QSTR_max_clients): {
+ val = MP_OBJ_NEW_SMALL_INT(cfg.ap.max_connection);
+ break;
+ }
default:
goto unknown;
}