@@ -317,7 +317,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_stop_station_obj, wifi_radio_stop_station);
317
317
//| *,
318
318
//| channel: int = 1,
319
319
//| authmode: Optional[AuthMode] = None,
320
- //| max_connections: Optional[int] = 4
320
+ //| max_connections: Optional[int] = 4,
321
321
//| ) -> None:
322
322
//| """Starts running an access point with the specified ssid and password.
323
323
//|
@@ -416,7 +416,7 @@ MP_PROPERTY_GETTER(wifi_radio_ap_active_obj,
416
416
//| *,
417
417
//| channel: int = 0,
418
418
//| bssid: Optional[Union[str | ReadableBuffer]] = None,
419
- //| timeout: Optional[float] = None
419
+ //| timeout: Optional[float] = None,
420
420
//| ) -> None:
421
421
//| """Connects to the given ssid and waits for an ip address. Reconnections are handled
422
422
//| automatically once one connection succeeds.
@@ -551,7 +551,7 @@ MP_PROPERTY_GETTER(wifi_radio_ipv4_subnet_ap_obj,
551
551
//| ipv4: ipaddress.IPv4Address,
552
552
//| netmask: ipaddress.IPv4Address,
553
553
//| gateway: ipaddress.IPv4Address,
554
- //| ipv4_dns: Optional[ipaddress.IPv4Address]
554
+ //| ipv4_dns: Optional[ipaddress.IPv4Address],
555
555
//| ) -> None:
556
556
//| """Sets the IP v4 address of the station. Must include the netmask and gateway. DNS address is optional.
557
557
//| 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
574
574
}
575
575
STATIC MP_DEFINE_CONST_FUN_OBJ_KW (wifi_radio_set_ipv4_address_obj , 1 , wifi_radio_set_ipv4_address );
576
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 );
602
+
577
603
//| ipv4_address: Optional[ipaddress.IPv4Address]
578
604
//| """IP v4 Address of the station when connected to an access point. None otherwise. (read-only)"""
579
605
STATIC 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) {
620
646
MP_DEFINE_CONST_FUN_OBJ_1 (wifi_radio_get_ap_info_obj , wifi_radio_get_ap_info );
621
647
622
648
//| def start_dhcp(self) -> None:
623
- //| """Starts the DHCP client."""
649
+ //| """Starts the station DHCP client."""
624
650
//| ...
625
651
STATIC mp_obj_t wifi_radio_start_dhcp_client (mp_obj_t self ) {
626
652
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) {
629
655
MP_DEFINE_CONST_FUN_OBJ_1 (wifi_radio_start_dhcp_client_obj , wifi_radio_start_dhcp_client );
630
656
631
657
//| 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."""
633
659
//| ...
634
660
STATIC mp_obj_t wifi_radio_stop_dhcp_client (mp_obj_t self ) {
635
661
common_hal_wifi_radio_stop_dhcp_client (self );
636
662
return mp_const_none ;
637
663
}
638
664
MP_DEFINE_CONST_FUN_OBJ_1 (wifi_radio_stop_dhcp_client_obj , wifi_radio_stop_dhcp_client );
639
665
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
+
640
684
MP_PROPERTY_GETTER (wifi_radio_ap_info_obj ,
641
685
(mp_obj_t )& wifi_radio_get_ap_info_obj );
642
686
@@ -693,6 +737,8 @@ STATIC const mp_rom_map_elem_t wifi_radio_locals_dict_table[] = {
693
737
694
738
{ MP_ROM_QSTR (MP_QSTR_start_dhcp ), MP_ROM_PTR (& wifi_radio_start_dhcp_client_obj ) },
695
739
{ 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 ) },
696
742
697
743
{ MP_ROM_QSTR (MP_QSTR_connect ), MP_ROM_PTR (& wifi_radio_connect_obj ) },
698
744
// { 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[] = {
708
754
{ MP_ROM_QSTR (MP_QSTR_ipv4_address_ap ), MP_ROM_PTR (& wifi_radio_ipv4_address_ap_obj ) },
709
755
710
756
{ 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 ) },
711
758
712
759
{ MP_ROM_QSTR (MP_QSTR_ping ), MP_ROM_PTR (& wifi_radio_ping_obj ) },
713
760
};
0 commit comments