@@ -657,8 +657,9 @@ STATIC mp_obj_t wlan_init_helper(mp_uint_t n_args, const mp_obj_t *pos_args, mp_
657657 nlr_raise (mp_obj_new_exception_msg (& mp_type_ValueError , mpexception_value_invalid_arguments ));
658658 }
659659
660- // Force the channel to be between 1-11
661- uint8_t channel = args [4 ].u_int > 0 ? args [4 ].u_int % 12 : 1 ;
660+ // force the channel to be between 1-11
661+ uint8_t channel = args [4 ].u_int ;
662+ channel = (channel > 0 && channel != 12 ) ? channel % 12 : 1 ;
662663
663664 if (MODWLAN_OK != wlan_sl_enable (args [0 ].u_int , ssid , ssid_len , args [2 ].u_int , key , key_len , channel )) {
664665 nlr_raise (mp_obj_new_exception_msg (& mp_type_OSError , mpexception_os_operation_failed ));
@@ -700,15 +701,15 @@ STATIC mp_obj_t wlan_make_new (mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_k
700701 mp_arg_check_num (n_args , n_kw , 0 , MP_ARRAY_SIZE (wlan_init_args ), true);
701702
702703 if (n_args > 0 ) {
703- // Get the mode
704+ // get the mode
704705 SlWlanMode_t mode = mp_obj_get_int (args [0 ]);
705706 if (mode == ROLE_AP ) {
706707 // start the peripheral
707708 mp_map_t kw_args ;
708709 mp_map_init_fixed_table (& kw_args , n_kw , args + n_args );
709710 wlan_init_helper (n_args , args , & kw_args );
710711 }
711- // TODO: Only STA mode supported for the moment. What if P2P?
712+ // TODO only STA mode supported for the moment. What if P2P?
712713 else if (n_args == 1 ) {
713714 if (MODWLAN_OK != wlan_sl_enable (mode , NULL , 0 , 0 , NULL , 0 , 0 )) {
714715 nlr_raise (mp_obj_new_exception_msg (& mp_type_OSError , mpexception_os_operation_failed ));
@@ -717,12 +718,9 @@ STATIC mp_obj_t wlan_make_new (mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_k
717718 else {
718719 nlr_raise (mp_obj_new_exception_msg (& mp_type_TypeError , mpexception_num_type_invalid_arguments ));
719720 }
720- } else if (wlan_obj .mode < 0 ) {
721- nlr_raise (mp_obj_new_exception_msg (& mp_type_TypeError , mpexception_num_type_invalid_arguments ));
722721 }
723722
724723 wlan_obj .base .type = (mp_obj_type_t * )& mod_network_nic_type_wlan ;
725-
726724 return & wlan_obj ;
727725}
728726
0 commit comments