@@ -545,34 +545,60 @@ MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ipv4_subnet_ap_obj, wifi_radio_get_ipv4
545545MP_PROPERTY_GETTER (wifi_radio_ipv4_subnet_ap_obj ,
546546 (mp_obj_t )& wifi_radio_get_ipv4_subnet_ap_obj );
547547
548- //| def set_ipv4_address(
549- //| self,
550- //| *,
551- //| ipv4: ipaddress.IPv4Address,
552- //| netmask: ipaddress.IPv4Address,
553- //| gateway: ipaddress.IPv4Address,
554- //| ipv4_dns: Optional[ipaddress.IPv4Address]
555- //| ) -> None:
556- //| """Sets the IP v4 address of the station. Must include the netmask and gateway. DNS address is optional.
557- //| Setting the address manually will stop the DHCP client."""
558- //| ...
559- STATIC mp_obj_t wifi_radio_set_ipv4_address (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
560- enum { ARG_ipv4 , ARG_netmask , ARG_gateway , ARG_ipv4_dns };
561- static const mp_arg_t allowed_args [] = {
562- { MP_QSTR_ipv4 , MP_ARG_REQUIRED | MP_ARG_KW_ONLY | MP_ARG_OBJ , },
563- { MP_QSTR_netmask , MP_ARG_REQUIRED | MP_ARG_KW_ONLY | MP_ARG_OBJ , },
564- { MP_QSTR_gateway , MP_ARG_REQUIRED | MP_ARG_KW_ONLY | MP_ARG_OBJ , },
565- { MP_QSTR_ipv4_dns , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_OBJ_NULL } },
566- };
567-
568- wifi_radio_obj_t * self = MP_OBJ_TO_PTR (pos_args [0 ]);
569- mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
570- mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
571-
572- common_hal_wifi_radio_set_ipv4_address (self , args [ARG_ipv4 ].u_obj , args [ARG_netmask ].u_obj , args [ARG_gateway ].u_obj , args [ARG_ipv4_dns ].u_obj );
573- return mp_const_none ;
574- }
575- STATIC MP_DEFINE_CONST_FUN_OBJ_KW (wifi_radio_set_ipv4_address_obj , 1 , wifi_radio_set_ipv4_address );
548+ //| def set_ipv4_address(
549+ //| self,
550+ //| *,
551+ //| ipv4: ipaddress.IPv4Address,
552+ //| netmask: ipaddress.IPv4Address,
553+ //| gateway: ipaddress.IPv4Address,
554+ //| ipv4_dns: Optional[ipaddress.IPv4Address]
555+ //| ) -> None:
556+ //| """Sets the IP v4 address of the station. Must include the netmask and gateway. DNS address is optional.
557+ //| Setting the address manually will stop the DHCP client."""
558+ //| ...
559+ STATIC mp_obj_t wifi_radio_set_ipv4_address (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
560+ enum { ARG_ipv4 , ARG_netmask , ARG_gateway , ARG_ipv4_dns };
561+ static const mp_arg_t allowed_args [] = {
562+ { MP_QSTR_ipv4 , MP_ARG_REQUIRED | MP_ARG_KW_ONLY | MP_ARG_OBJ , },
563+ { MP_QSTR_netmask , MP_ARG_REQUIRED | MP_ARG_KW_ONLY | MP_ARG_OBJ , },
564+ { MP_QSTR_gateway , MP_ARG_REQUIRED | MP_ARG_KW_ONLY | MP_ARG_OBJ , },
565+ { MP_QSTR_ipv4_dns , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_OBJ_NULL } },
566+ };
567+
568+ wifi_radio_obj_t * self = MP_OBJ_TO_PTR (pos_args [0 ]);
569+ mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
570+ mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
571+
572+ common_hal_wifi_radio_set_ipv4_address (self , args [ARG_ipv4 ].u_obj , args [ARG_netmask ].u_obj , args [ARG_gateway ].u_obj , args [ARG_ipv4_dns ].u_obj );
573+ return mp_const_none ;
574+ }
575+ STATIC MP_DEFINE_CONST_FUN_OBJ_KW (wifi_radio_set_ipv4_address_obj , 1 , wifi_radio_set_ipv4_address );
576+
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 );
576602
577603//| ipv4_address: Optional[ipaddress.IPv4Address]
578604//| """IP v4 Address of the station when connected to an access point. None otherwise. (read-only)"""
@@ -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 client."""
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 client. 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