@@ -414,6 +414,27 @@ MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ipv4_subnet_ap_obj, wifi_radio_get_ipv4
414
414
MP_PROPERTY_GETTER (wifi_radio_ipv4_subnet_ap_obj ,
415
415
(mp_obj_t )& wifi_radio_get_ipv4_subnet_ap_obj );
416
416
417
+ //| def set_ipv4_address(self, ipv4: ipaddress.IPv4Address, netmask: ipaddress.IPv4Address, gateway: ipaddress.IPv4Address) -> None:
418
+ //| """Sets the IP v4 address of the station. Must include the netmask and gateway.
419
+ //| Setting the address manually will stop the DHCP client."""
420
+ //| ...
421
+ STATIC mp_obj_t wifi_radio_set_ipv4_address (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
422
+ enum { ARG_ipv4 , ARG_netmask , ARG_gateway };
423
+ static const mp_arg_t allowed_args [] = {
424
+ { MP_QSTR_ipv4 , MP_ARG_REQUIRED | MP_ARG_OBJ , },
425
+ { MP_QSTR_netmask , MP_ARG_REQUIRED | MP_ARG_OBJ , },
426
+ { MP_QSTR_gateway , MP_ARG_REQUIRED | MP_ARG_OBJ , },
427
+ };
428
+
429
+ wifi_radio_obj_t * self = MP_OBJ_TO_PTR (pos_args [0 ]);
430
+ mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
431
+ mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
432
+
433
+ common_hal_wifi_radio_set_ipv4_address (self , args [ARG_ipv4 ].u_obj , args [ARG_netmask ].u_obj , args [ARG_gateway ].u_obj );
434
+ return mp_const_none ;
435
+ }
436
+ STATIC MP_DEFINE_CONST_FUN_OBJ_KW (wifi_radio_set_ipv4_address_obj , 4 , wifi_radio_set_ipv4_address );
437
+
417
438
//| ipv4_address: Optional[ipaddress.IPv4Address]
418
439
//| """IP v4 Address of the station when connected to an access point. None otherwise."""
419
440
//|
@@ -459,6 +480,26 @@ STATIC mp_obj_t wifi_radio_get_ap_info(mp_obj_t self) {
459
480
}
460
481
MP_DEFINE_CONST_FUN_OBJ_1 (wifi_radio_get_ap_info_obj , wifi_radio_get_ap_info );
461
482
483
+ //| def wifi_radio_start_dhcp_client(self) -> None:
484
+ //| """Starts the DHCP client."""
485
+ //| ...
486
+ //|
487
+ STATIC mp_obj_t wifi_radio_start_dhcp_client (mp_obj_t self ) {
488
+ common_hal_wifi_radio_start_dhcp_client (self );
489
+ return mp_const_none ;
490
+ }
491
+ MP_DEFINE_CONST_FUN_OBJ_1 (wifi_radio_start_dhcp_client_obj , wifi_radio_start_dhcp_client );
492
+
493
+ //| def wifi_radio_stop_dhcp_client(self) -> None:
494
+ //| """Stops the DHCP client. Needed to assign a static IP address."""
495
+ //| ...
496
+ //|
497
+ STATIC mp_obj_t wifi_radio_stop_dhcp_client (mp_obj_t self ) {
498
+ common_hal_wifi_radio_stop_dhcp_client (self );
499
+ return mp_const_none ;
500
+ }
501
+ MP_DEFINE_CONST_FUN_OBJ_1 (wifi_radio_stop_dhcp_client_obj , wifi_radio_stop_dhcp_client );
502
+
462
503
MP_PROPERTY_GETTER (wifi_radio_ap_info_obj ,
463
504
(mp_obj_t )& wifi_radio_get_ap_info_obj );
464
505
@@ -509,6 +550,9 @@ STATIC const mp_rom_map_elem_t wifi_radio_locals_dict_table[] = {
509
550
{ MP_ROM_QSTR (MP_QSTR_start_ap ), MP_ROM_PTR (& wifi_radio_start_ap_obj ) },
510
551
{ MP_ROM_QSTR (MP_QSTR_stop_ap ), MP_ROM_PTR (& wifi_radio_stop_ap_obj ) },
511
552
553
+ { MP_ROM_QSTR (MP_QSTR_start_dhcp ), MP_ROM_PTR (& wifi_radio_start_dhcp_client_obj ) },
554
+ { MP_ROM_QSTR (MP_QSTR_stop_dhcp ), MP_ROM_PTR (& wifi_radio_stop_dhcp_client_obj ) },
555
+
512
556
{ MP_ROM_QSTR (MP_QSTR_connect ), MP_ROM_PTR (& wifi_radio_connect_obj ) },
513
557
// { MP_ROM_QSTR(MP_QSTR_connect_to_enterprise), MP_ROM_PTR(&wifi_radio_connect_to_enterprise_obj) },
514
558
@@ -521,6 +565,8 @@ STATIC const mp_rom_map_elem_t wifi_radio_locals_dict_table[] = {
521
565
{ MP_ROM_QSTR (MP_QSTR_ipv4_address ), MP_ROM_PTR (& wifi_radio_ipv4_address_obj ) },
522
566
{ MP_ROM_QSTR (MP_QSTR_ipv4_address_ap ), MP_ROM_PTR (& wifi_radio_ipv4_address_ap_obj ) },
523
567
568
+ { MP_ROM_QSTR (MP_QSTR_set_ipv4_address ), MP_ROM_PTR (& wifi_radio_set_ipv4_address_obj ) },
569
+
524
570
// { MP_ROM_QSTR(MP_QSTR_access_point_active), MP_ROM_PTR(&wifi_radio_access_point_active_obj) },
525
571
// { MP_ROM_QSTR(MP_QSTR_start_access_point), MP_ROM_PTR(&wifi_radio_start_access_point_obj) },
526
572
0 commit comments