Skip to content

Commit 74589cb

Browse files
committed
cc3200: Move code that disables/enables servers to wlan_sl_enable().
1 parent 5330d89 commit 74589cb

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

cc3200/mods/modwlan.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,12 @@ modwlan_Status_t wlan_sl_enable (SlWlanMode_t mode, const char *ssid, uint8_t ss
362362
const char *key, uint8_t key_len, uint8_t channel) {
363363

364364
if (mode == ROLE_STA || mode == ROLE_AP || mode == ROLE_P2P) {
365+
#if (MICROPY_PORT_HAS_TELNET || MICROPY_PORT_HAS_FTP)
366+
// Stop all other processes using the wlan engine
367+
if ((wlan_obj.servers_enabled = servers_are_enabled())) {
368+
wlan_stop_servers();
369+
}
370+
#endif
365371
if (wlan_obj.mode < 0) {
366372
wlan_obj.mode = sl_Start(0, 0, 0);
367373
sl_LockObjUnlock (&wlan_LockObj);
@@ -486,6 +492,12 @@ modwlan_Status_t wlan_sl_enable (SlWlanMode_t mode, const char *ssid, uint8_t ss
486492
wlan_reenable(mode);
487493
}
488494
}
495+
#if (MICROPY_PORT_HAS_TELNET || MICROPY_PORT_HAS_FTP)
496+
// Start the servers again
497+
if (wlan_obj.servers_enabled) {
498+
servers_enable();
499+
}
500+
#endif
489501
return MODWLAN_OK;
490502
}
491503
return MODWLAN_ERROR_INVALID_PARAMS;
@@ -674,13 +686,6 @@ STATIC mp_obj_t wlan_make_new (mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_k
674686
if (n_args > 0) {
675687
// Get the mode
676688
SlWlanMode_t mode = mp_obj_get_int(args[0]);
677-
678-
#if (MICROPY_PORT_HAS_TELNET || MICROPY_PORT_HAS_FTP)
679-
// Stop all other processes using the wlan engine
680-
if ((wlan_obj.servers_enabled = servers_are_enabled())) {
681-
wlan_stop_servers();
682-
}
683-
#endif
684689
if (mode == ROLE_AP) {
685690
// start the peripheral
686691
mp_map_t kw_args;
@@ -696,12 +701,6 @@ STATIC mp_obj_t wlan_make_new (mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_k
696701
else {
697702
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, mpexception_num_type_invalid_arguments));
698703
}
699-
#if (MICROPY_PORT_HAS_TELNET || MICROPY_PORT_HAS_FTP)
700-
// Start the servers again
701-
if (wlan_obj.servers_enabled) {
702-
servers_enable();
703-
}
704-
#endif
705704
} else if (wlan_obj.mode < 0) {
706705
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, mpexception_num_type_invalid_arguments));
707706
}

cc3200/mptask.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ STATIC void main_init_sflash_filesystem (void) {
319319

320320
STATIC void main_enter_ap_mode (void) {
321321
// Enable simplelink in low power mode
322-
wlan_sl_enable (ROLE_AP, SERVERS_DEF_AP_SSID, strlen(SERVERS_DEF_AP_SSID), SL_SEC_TYPE_WPA_WPA2,
322+
wlan_sl_enable (ROLE_AP, SERVERS_DEF_AP_SSID, strlen(SERVERS_DEF_AP_SSID), SERVERS_DEF_AP_SECURITY,
323323
SERVERS_DEF_AP_KEY, strlen(SERVERS_DEF_AP_KEY), SERVERS_DEF_AP_CHANNEL);
324324
wlan_set_pm_policy (SL_NORMAL_POLICY);
325325
}

cc3200/serverstask.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#define SERVERS_PASS_LEN_MAX 16
4141

4242
#define SERVERS_DEF_AP_SSID "micropy-wlan"
43+
#define SERVERS_DEF_AP_SECURITY SL_SEC_TYPE_WPA_WPA2
4344
#define SERVERS_DEF_AP_KEY "micropython"
4445
#define SERVERS_DEF_AP_CHANNEL 6
4546

0 commit comments

Comments
 (0)