@@ -89,14 +89,29 @@ static void network_cyw43_print(const mp_print_t *print, mp_obj_t self_in, mp_pr
89
89
);
90
90
}
91
91
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
92
104
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 ) {
93
105
mp_arg_check_num (n_args , n_kw , 0 , 1 , false);
94
106
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 );
96
108
} else {
97
- return MP_OBJ_FROM_PTR ( & network_cyw43_wl_ap );
109
+ return network_cyw43_get_interface ( MOD_NETWORK_AP_IF );
98
110
}
99
111
}
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
100
115
101
116
static mp_obj_t network_cyw43_send_ethernet (mp_obj_t self_in , mp_obj_t buf_in ) {
102
117
network_cyw43_obj_t * self = MP_OBJ_TO_PTR (self_in );
@@ -558,7 +573,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
558
573
mp_network_cyw43_type ,
559
574
MP_QSTR_CYW43 ,
560
575
MP_TYPE_FLAG_NONE ,
561
- make_new , network_cyw43_make_new ,
576
+ make_new , MICROPY_PY_NETWORK_CYW43_MAKE_NEW ,
562
577
print , network_cyw43_print ,
563
578
locals_dict , & network_cyw43_locals_dict
564
579
);
0 commit comments