Skip to content

Commit 1580e33

Browse files
author
Daniel Campora
committed
cc3200: Make small changes in WLAN to improve the API.
1 parent 6d1ff7e commit 1580e33

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

cc3200/mods/modwlan.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -623,9 +623,9 @@ STATIC bool wlan_is_connected (void) {
623623
GET_STATUS_BIT(wlan_obj.status, STATUS_BIT_IP_ACQUIRED)) || wlan_obj.staconnected);
624624
}
625625

626-
/// \method init(mode, ssid=myWlan, security=wlan.WPA_WPA2, key=myWlanKey)
626+
/// \method init(mode, ssid=None, *, security=wlan.OPEN, key=None, channel=5)
627627
///
628-
/// Initialise the UART bus with the given parameters:
628+
/// Initialise the WLAN engine with the given parameters:
629629
///
630630
/// - `mode` can be ROLE_AP, ROLE_STA and ROLE_P2P.
631631
/// - `ssid` is the network ssid in case of AP mode
@@ -634,7 +634,7 @@ STATIC bool wlan_is_connected (void) {
634634
/// - `channel` is the channel to use for the AP network
635635
STATIC const mp_arg_t wlan_init_args[] = {
636636
{ MP_QSTR_mode, MP_ARG_REQUIRED | MP_ARG_INT, {.u_int = ROLE_STA} },
637-
{ MP_QSTR_ssid, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
637+
{ MP_QSTR_ssid, MP_ARG_OBJ, {.u_obj = mp_const_none} },
638638
{ MP_QSTR_security, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = SL_SEC_TYPE_OPEN} },
639639
{ MP_QSTR_key, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
640640
{ MP_QSTR_channel, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 5} },
@@ -724,15 +724,15 @@ STATIC mp_obj_t wlan_make_new (mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_k
724724
return &wlan_obj;
725725
}
726726

727-
/// \method connect(ssid, security=OPEN, key=None, bssid=None)
727+
/// \method connect(ssid, *, security=OPEN, key=None, bssid=None, timeout=5000)
728728
// if security is WPA/WPA2, the key must be a string
729729
/// if security is WEP, the key must be binary
730730
STATIC mp_obj_t wlan_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
731731
STATIC const mp_arg_t allowed_args[] = {
732-
{ MP_QSTR_ssid, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
732+
{ MP_QSTR_ssid, MP_ARG_REQUIRED | MP_ARG_OBJ, },
733733
{ MP_QSTR_security, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = SL_SEC_TYPE_OPEN} },
734-
{ MP_QSTR_key, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
735-
{ MP_QSTR_bssid, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
734+
{ MP_QSTR_key, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
735+
{ MP_QSTR_bssid, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
736736
{ MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = MODWLAN_TIMEOUT_MS} },
737737
};
738738

@@ -756,21 +756,21 @@ STATIC mp_obj_t wlan_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_
756756
mp_uint_t key_len = 0;
757757
const char *key = NULL;
758758
mp_buffer_info_t wepkey;
759-
if (args[2].u_obj != mp_const_none) {
759+
mp_obj_t key_o = args[2].u_obj;
760+
if (key_o != MP_OBJ_NULL) {
760761
// wep key must be given as raw bytes
761762
if (sec == SL_SEC_TYPE_WEP) {
762-
mp_get_buffer_raise(args[2].u_obj, &wepkey, MP_BUFFER_READ);
763+
mp_get_buffer_raise(key_o, &wepkey, MP_BUFFER_READ);
763764
key = wepkey.buf;
764765
key_len = wepkey.len;
765-
}
766-
else {
767-
key = mp_obj_str_get_data(args[2].u_obj, &key_len);
766+
} else {
767+
key = mp_obj_str_get_data(key_o, &key_len);
768768
}
769769
}
770770

771771
// get bssid
772772
const char *bssid = NULL;
773-
if (args[3].u_obj != mp_const_none) {
773+
if (args[3].u_obj != MP_OBJ_NULL) {
774774
bssid = mp_obj_str_get_str(args[3].u_obj);
775775
}
776776

0 commit comments

Comments
 (0)