cc3200: Move code that disables/enables servers to wlan_sl_enable().
This commit is contained in:
parent
5330d8996f
commit
74589cbeeb
@ -362,6 +362,12 @@ modwlan_Status_t wlan_sl_enable (SlWlanMode_t mode, const char *ssid, uint8_t ss
|
|||||||
const char *key, uint8_t key_len, uint8_t channel) {
|
const char *key, uint8_t key_len, uint8_t channel) {
|
||||||
|
|
||||||
if (mode == ROLE_STA || mode == ROLE_AP || mode == ROLE_P2P) {
|
if (mode == ROLE_STA || mode == ROLE_AP || mode == ROLE_P2P) {
|
||||||
|
#if (MICROPY_PORT_HAS_TELNET || MICROPY_PORT_HAS_FTP)
|
||||||
|
// Stop all other processes using the wlan engine
|
||||||
|
if ((wlan_obj.servers_enabled = servers_are_enabled())) {
|
||||||
|
wlan_stop_servers();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (wlan_obj.mode < 0) {
|
if (wlan_obj.mode < 0) {
|
||||||
wlan_obj.mode = sl_Start(0, 0, 0);
|
wlan_obj.mode = sl_Start(0, 0, 0);
|
||||||
sl_LockObjUnlock (&wlan_LockObj);
|
sl_LockObjUnlock (&wlan_LockObj);
|
||||||
@ -486,6 +492,12 @@ modwlan_Status_t wlan_sl_enable (SlWlanMode_t mode, const char *ssid, uint8_t ss
|
|||||||
wlan_reenable(mode);
|
wlan_reenable(mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if (MICROPY_PORT_HAS_TELNET || MICROPY_PORT_HAS_FTP)
|
||||||
|
// Start the servers again
|
||||||
|
if (wlan_obj.servers_enabled) {
|
||||||
|
servers_enable();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return MODWLAN_OK;
|
return MODWLAN_OK;
|
||||||
}
|
}
|
||||||
return MODWLAN_ERROR_INVALID_PARAMS;
|
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
|
|||||||
if (n_args > 0) {
|
if (n_args > 0) {
|
||||||
// Get the mode
|
// Get the mode
|
||||||
SlWlanMode_t mode = mp_obj_get_int(args[0]);
|
SlWlanMode_t mode = mp_obj_get_int(args[0]);
|
||||||
|
|
||||||
#if (MICROPY_PORT_HAS_TELNET || MICROPY_PORT_HAS_FTP)
|
|
||||||
// Stop all other processes using the wlan engine
|
|
||||||
if ((wlan_obj.servers_enabled = servers_are_enabled())) {
|
|
||||||
wlan_stop_servers();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (mode == ROLE_AP) {
|
if (mode == ROLE_AP) {
|
||||||
// start the peripheral
|
// start the peripheral
|
||||||
mp_map_t kw_args;
|
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
|
|||||||
else {
|
else {
|
||||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, mpexception_num_type_invalid_arguments));
|
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, mpexception_num_type_invalid_arguments));
|
||||||
}
|
}
|
||||||
#if (MICROPY_PORT_HAS_TELNET || MICROPY_PORT_HAS_FTP)
|
|
||||||
// Start the servers again
|
|
||||||
if (wlan_obj.servers_enabled) {
|
|
||||||
servers_enable();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
} else if (wlan_obj.mode < 0) {
|
} else if (wlan_obj.mode < 0) {
|
||||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, mpexception_num_type_invalid_arguments));
|
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, mpexception_num_type_invalid_arguments));
|
||||||
}
|
}
|
||||||
|
@ -319,7 +319,7 @@ STATIC void main_init_sflash_filesystem (void) {
|
|||||||
|
|
||||||
STATIC void main_enter_ap_mode (void) {
|
STATIC void main_enter_ap_mode (void) {
|
||||||
// Enable simplelink in low power mode
|
// Enable simplelink in low power mode
|
||||||
wlan_sl_enable (ROLE_AP, SERVERS_DEF_AP_SSID, strlen(SERVERS_DEF_AP_SSID), SL_SEC_TYPE_WPA_WPA2,
|
wlan_sl_enable (ROLE_AP, SERVERS_DEF_AP_SSID, strlen(SERVERS_DEF_AP_SSID), SERVERS_DEF_AP_SECURITY,
|
||||||
SERVERS_DEF_AP_KEY, strlen(SERVERS_DEF_AP_KEY), SERVERS_DEF_AP_CHANNEL);
|
SERVERS_DEF_AP_KEY, strlen(SERVERS_DEF_AP_KEY), SERVERS_DEF_AP_CHANNEL);
|
||||||
wlan_set_pm_policy (SL_NORMAL_POLICY);
|
wlan_set_pm_policy (SL_NORMAL_POLICY);
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#define SERVERS_PASS_LEN_MAX 16
|
#define SERVERS_PASS_LEN_MAX 16
|
||||||
|
|
||||||
#define SERVERS_DEF_AP_SSID "micropy-wlan"
|
#define SERVERS_DEF_AP_SSID "micropy-wlan"
|
||||||
|
#define SERVERS_DEF_AP_SECURITY SL_SEC_TYPE_WPA_WPA2
|
||||||
#define SERVERS_DEF_AP_KEY "micropython"
|
#define SERVERS_DEF_AP_KEY "micropython"
|
||||||
#define SERVERS_DEF_AP_CHANNEL 6
|
#define SERVERS_DEF_AP_CHANNEL 6
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user