@@ -93,14 +93,35 @@ static void network_cyw43_print(const mp_print_t *print, mp_obj_t self_in, mp_pr
9393 );
9494}
9595
96- static mp_obj_t network_cyw43_make_new (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * args ) {
97- mp_arg_check_num (n_args , n_kw , 0 , 1 , false);
98- if (n_args == 0 || mp_obj_get_int (args [0 ]) == MOD_NETWORK_STA_IF ) {
96+ // Allow the port to add extra parameters
97+ #ifdef MICROPY_PY_NETWORK_CYW43_OBJ_INIT_ARGS
98+ #define EXTRA_ARGS MICROPY_PY_NETWORK_CYW43_OBJ_INIT_ARGS
99+ #else
100+ #define EXTRA_ARGS
101+ #endif
102+
103+ MP_WEAK void network_cyw43_obj_init (mp_arg_val_t * args ) {
104+ }
105+
106+ static mp_obj_t network_cyw43_make_new (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * all_args ) {
107+ enum { ARG_interface , ARG_last };
108+ const mp_arg_t allowed_args [] = {
109+ { MP_QSTR_interface , MP_ARG_INT , {.u_int = MOD_NETWORK_STA_IF } },
110+ EXTRA_ARGS
111+ };
112+ mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
113+ mp_map_t kw_args ;
114+ mp_map_init_fixed_table (& kw_args , n_kw , all_args + n_args );
115+ mp_arg_parse_all (n_args , all_args , & kw_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
116+
117+ network_cyw43_obj_init (args + ARG_last );
118+ if (args [ARG_interface ].u_int == MOD_NETWORK_STA_IF ) {
99119 return MP_OBJ_FROM_PTR (& network_cyw43_wl_sta );
100120 } else {
101121 return MP_OBJ_FROM_PTR (& network_cyw43_wl_ap );
102122 }
103123}
124+ #undef EXTRA_ARGS
104125
105126static mp_obj_t network_cyw43_send_ethernet (mp_obj_t self_in , mp_obj_t buf_in ) {
106127 network_cyw43_obj_t * self = MP_OBJ_TO_PTR (self_in );
0 commit comments