8000 esp32/modnetwork: Add max_clients kw-arg to WLAN.config for AP setting. · andrewleech/micropython@a55c17d · GitHub
[go: up one dir, main page]

Skip to content

Commit a55c17d

Browse files
adzierzanowskidpgeorge
authored andcommitted
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 micropython#5125.
1 parent 59746ac commit a55c17d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

docs/esp32/quickref.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ The :mod:`network` module::
8282

8383
ap = network.WLAN(network.AP_IF) # create access-point interface
8484
ap.config(essid='ESP-AP') # set the ESSID of the access point
85+
ap.config(max_clients=10) # set how many clients can connect to the network
8586
ap.active(True) # activate the interface
8687

8788
A useful function for connecting to your local WiFi network is::

ports/esp32/modnetwork.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,11 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
619619
ESP_EXCEPTIONS(tcpip_adapter_set_hostname(self->if_id, s));
620620
break;
621621
}
622+
case QS(MP_QSTR_max_clients): {
623+
req_if = WIFI_IF_AP;
624+
cfg.ap.max_connection = mp_obj_get_int(kwargs->table[i].value);
625+
break;
626+
}
622627
default:
623628
goto unknown;
624629
}
@@ -693,6 +698,10 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
693698
val = mp_obj_new_str(s, strlen(s));
694699
break;
695700
}
701+
case QS(MP_QSTR_max_clients): {
702+
val = MP_OBJ_NEW_SMALL_INT(cfg.ap.max_connection);
703+
break;
704+
}
696705
default:
697706
goto unknown;
698707
}

0 commit comments

Comments
 (0)
0