@@ -317,7 +317,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_stop_station_obj, wifi_radio_stop_station);
317317//| *,
318318//| channel: int = 1,
319319//| authmode: Optional[AuthMode] = None,
320- //| max_connections: Optional[int] = 4
320+ //| max_connections: Optional[int] = 4,
321321//| ) -> None:
322322//| """Starts running an access point with the specified ssid and password.
323323//|
@@ -416,7 +416,7 @@ MP_PROPERTY_GETTER(wifi_radio_ap_active_obj,
416416//| *,
417417//| channel: int = 0,
418418//| bssid: Optional[Union[str | ReadableBuffer]] = None,
419- //| timeout: Optional[float] = None
419+ //| timeout: Optional[float] = None,
420420//| ) -> None:
421421//| """Connects to the given ssid and waits for an ip address. Reconnections are handled
422422//| automatically once one connection succeeds.
@@ -551,7 +551,7 @@ MP_PROPERTY_GETTER(wifi_radio_ipv4_subnet_ap_obj,
551551//| ipv4: ipaddress.IPv4Address,
552552//| netmask: ipaddress.IPv4Address,
553553//| gateway: ipaddress.IPv4Address,
554- //| ipv4_dns: Optional[ipaddress.IPv4Address]
554+ //| ipv4_dns: Optional[ipaddress.IPv4Address],
555555//| ) -> None:
556556//| """Sets the IP v4 address of the station. Must include the netmask and gateway. DNS address is optional.
557557//| Setting the address manually will stop the DHCP client."""
@@ -574,6 +574,32 @@ STATIC mp_obj_t wifi_radio_set_ipv4_address(size_t n_args, const mp_obj_t *pos_a
574574}
575575STATIC MP_DEFINE_CONST_FUN_OBJ_KW (wifi_radio_set_ipv4_address_obj , 1 , wifi_radio_set_ipv4_address );
576576
577+ //| def set_ipv4_address_ap(
578+ //| self,
579+ //| *,
580+ //| ipv4: ipaddress.IPv4Address,
581+ //| netmask: ipaddress.IPv4Address,
582+ //| gateway: ipaddress.IPv4Address,
583+ //| ) -> None:
584+ //| """Sets the IP v4 address of the access point. Must include the netmask and gateway."""
585+ //| ...
586+ STATIC mp_obj_t wifi_radio_set_ipv4_address_ap (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
587+ enum { ARG_ipv4 , ARG_netmask , ARG_gateway };
588+ static const mp_arg_t allowed_args [] = {
589+ { MP_QSTR_ipv4 , MP_ARG_REQUIRED | MP_ARG_KW_ONLY | MP_ARG_OBJ , },
590+ { MP_QSTR_netmask , MP_ARG_REQUIRED | MP_ARG_KW_ONLY | MP_ARG_OBJ , },
591+ { MP_QSTR_gateway , MP_ARG_REQUIRED | MP_ARG_KW_ONLY | MP_ARG_OBJ , },
592+ };
593+
594+ wifi_radio_obj_t * self = MP_OBJ_TO_PTR (pos_args [0 ]);
595+ mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
596+ mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
597+
598+ common_hal_wifi_radio_set_ipv4_address_ap (self , args [ARG_ipv4 ].u_obj , args [ARG_netmask ].u_obj , args [ARG_gateway ].u_obj );
599+ return mp_const_none ;
600+ }
601+ STATIC MP_DEFINE_CONST_FUN_OBJ_KW (wifi_radio_set_ipv4_address_ap_obj , 1 , wifi_radio_set_ipv4_address_ap );
602+
577603//| ipv4_address: Optional[ipaddress.IPv4Address]
578604//| """IP v4 Address of the station when connected to an access point. None otherwise. (read-only)"""
579605STATIC mp_obj_t _wifi_radio_get_ipv4_address (mp_obj_t self ) {
@@ -620,7 +646,7 @@ STATIC mp_obj_t wifi_radio_get_ap_info(mp_obj_t self) {
620646MP_DEFINE_CONST_FUN_OBJ_1 (wifi_radio_get_ap_info_obj , wifi_radio_get_ap_info );
621647
622648//| def start_dhcp(self) -> None:
623- //| """Starts the DHCP client."""
649+ //| """Starts the station DHCP client."""
624650//| ...
625651STATIC mp_obj_t wifi_radio_start_dhcp_client (mp_obj_t self ) {
626652 common_hal_wifi_radio_start_dhcp_client (self );
@@ -629,14 +655,32 @@ STATIC mp_obj_t wifi_radio_start_dhcp_client(mp_obj_t self) {
629655MP_DEFINE_CONST_FUN_OBJ_1 (wifi_radio_start_dhcp_client_obj , wifi_radio_start_dhcp_client );
630656
631657//| def stop_dhcp(self) -> None:
632- //| """Stops the DHCP client. Needed to assign a static IP address."""
658+ //| """Stops the station DHCP client. Needed to assign a static IP address."""
633659//| ...
634660STATIC mp_obj_t wifi_radio_stop_dhcp_client (mp_obj_t self ) {
635661 common_hal_wifi_radio_stop_dhcp_client (self );
636662 return mp_const_none ;
637663}
638664MP_DEFINE_CONST_FUN_OBJ_1 (wifi_radio_stop_dhcp_client_obj , wifi_radio_stop_dhcp_client );
639665
666+ //| def start_dhcp_ap(self) -> None:
667+ //| """Starts the access point DHCP server."""
668+ //| ...
669+ STATIC mp_obj_t wifi_radio_start_dhcp_server (mp_obj_t self ) {
670+ common_hal_wifi_radio_start_dhcp_server (self );
671+ return mp_const_none ;
672+ }
673+ MP_DEFINE_CONST_FUN_OBJ_1 (wifi_radio_start_dhcp_server_obj , wifi_radio_start_dhcp_server );
674+
675+ //| def stop_dhcp_ap(self) -> None:
676+ //| """Stops the access point DHCP server. Needed to assign a static IP address."""
677+ //| ...
678+ STATIC mp_obj_t wifi_radio_stop_dhcp_server (mp_obj_t self ) {
679+ common_hal_wifi_radio_stop_dhcp_server (self );
680+ return mp_const_none ;
681+ }
682+ MP_DEFINE_CONST_FUN_OBJ_1 (wifi_radio_stop_dhcp_server_obj , wifi_radio_stop_dhcp_server );
683+
640684MP_PROPERTY_GETTER (wifi_radio_ap_info_obj ,
641685 (mp_obj_t )& wifi_radio_get_ap_info_obj );
642686
@@ -693,6 +737,8 @@ STATIC const mp_rom_map_elem_t wifi_radio_locals_dict_table[] = {
693737
694738 { MP_ROM_QSTR (MP_QSTR_start_dhcp ), MP_ROM_PTR (& wifi_radio_start_dhcp_client_obj ) },
695739 { MP_ROM_QSTR (MP_QSTR_stop_dhcp ), MP_ROM_PTR (& wifi_radio_stop_dhcp_client_obj ) },
740+ { MP_ROM_QSTR (MP_QSTR_start_dhcp_ap ), MP_ROM_PTR (& wifi_radio_start_dhcp_server_obj ) },
741+ { MP_ROM_QSTR (MP_QSTR_stop_dhcp_ap ), MP_ROM_PTR (& wifi_radio_stop_dhcp_server_obj ) },
696742
697743 { MP_ROM_QSTR (MP_QSTR_connect ), MP_ROM_PTR (& wifi_radio_connect_obj ) },
698744 // { MP_ROM_QSTR(MP_QSTR_connect_to_enterprise), MP_ROM_PTR(&wifi_radio_connect_to_enterprise_obj) },
@@ -708,6 +754,7 @@ STATIC const mp_rom_map_elem_t wifi_radio_locals_dict_table[] = {
708754 { MP_ROM_QSTR (MP_QSTR_ipv4_address_ap ), MP_ROM_PTR (& wifi_radio_ipv4_address_ap_obj ) },
709755
710756 { MP_ROM_QSTR (MP_QSTR_set_ipv4_address ), MP_ROM_PTR (& wifi_radio_set_ipv4_address_obj ) },
757+ { MP_ROM_QSTR (MP_QSTR_set_ipv4_address_ap ), MP_ROM_PTR (& wifi_radio_set_ipv4_address_ap_obj ) },
711758
712759 { MP_ROM_QSTR (MP_QSTR_ping ), MP_ROM_PTR (& wifi_radio_ping_obj ) },
713760};
0 commit comments