@@ -89,14 +89,29 @@ static void network_cyw43_print(const mp_print_t *print, mp_obj_t self_in, mp_pr
8989 );
9090}
9191
92+
93+ mp_obj_t network_cyw43_get_interface (mp_int_t type ) {
94+ if (type == MOD_NETWORK_STA_IF ) {
95+ return MP_OBJ_FROM_PTR (& network_cyw43_wl_sta );
96+ } else {
97+ return MP_OBJ_FROM_PTR (& network_cyw43_wl_ap );
98+ }
99+ }
100+
101+ // Allow network_cyw43_make_new to be overridden
102+ #ifndef MICROPY_PY_NETWORK_CYW43_MAKE_NEW
103+ #define MICROPY_PY_NETWORK_CYW43_MAKE_NEW network_cyw43_make_new
92104static 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 ) {
93105 mp_arg_check_num (n_args , n_kw , 0 , 1 , false);
94106 if (n_args == 0 || mp_obj_get_int (args [0 ]) == MOD_NETWORK_STA_IF ) {
95- return MP_OBJ_FROM_PTR ( & network_cyw43_wl_sta );
107+ return network_cyw43_get_interface ( MOD_NETWORK_STA_IF );
96108 } else {
97- return MP_OBJ_FROM_PTR ( & network_cyw43_wl_ap );
109+ return network_cyw43_get_interface ( MOD_NETWORK_AP_IF );
98110 }
99111}
112+ #else
113+ mp_obj_t MICROPY_PY_NETWORK_CYW43_MAKE_NEW (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * args );
114+ #endif
100115
101116static mp_obj_t network_cyw43_send_ethernet (mp_obj_t self_in , mp_obj_t buf_in ) {
102117 network_cyw43_obj_t * self = MP_OBJ_TO_PTR (self_in );
@@ -558,7 +573,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
558573 mp_network_cyw43_type ,
559574 MP_QSTR_CYW43 ,
560575 MP_TYPE_FLAG_NONE ,
561- make_new , network_cyw43_make_new ,
576+ make_new , MICROPY_PY_NETWORK_CYW43_MAKE_NEW ,
562577 print , network_cyw43_print ,
563578 locals_dict , & network_cyw43_locals_dict
564579 );
0 commit comments