cc3200: Roll back to the previous telnet and ftp timeouts.
Unfortunately, these timeouts are the only realiable way (for now), to be able to detect broken connections due to half-open sockets. Such a thing occurs when getting out of the WiFi coverage area or when disconnecting from the AP (sometimes the client doesn't send the disconnect packet).
This commit is contained in:
parent
e15f8198bc
commit
684dba40f0
@ -67,7 +67,7 @@
|
|||||||
#define FTP_UNIX_TIME_20150101 1420070400
|
#define FTP_UNIX_TIME_20150101 1420070400
|
||||||
#define FTP_UNIX_SECONDS_180_DAYS 15552000
|
#define FTP_UNIX_SECONDS_180_DAYS 15552000
|
||||||
#define FTP_DATA_TIMEOUT_MS 5000 // 5 seconds
|
#define FTP_DATA_TIMEOUT_MS 5000 // 5 seconds
|
||||||
#define FTP_CMD_TIMEOUT_MS 300000 // 5 minutes
|
#define FTP_CMD_TIMEOUT_MS 120000 // 2 minutes
|
||||||
#define FTP_SOCKETFIFO_ELEMENTS_MAX 4
|
#define FTP_SOCKETFIFO_ELEMENTS_MAX 4
|
||||||
#define FTP_CYCLE_TIME_MS (SERVERS_CYCLE_TIME_MS * 2)
|
#define FTP_CYCLE_TIME_MS (SERVERS_CYCLE_TIME_MS * 2)
|
||||||
|
|
||||||
@ -224,6 +224,7 @@ static ftp_result_t ftp_list_dir (char *list, uint32_t maxlistsize, uint32_t *li
|
|||||||
static void ftp_open_child (char *pwd, char *dir);
|
static void ftp_open_child (char *pwd, char *dir);
|
||||||
static void ftp_close_child (char *pwd);
|
static void ftp_close_child (char *pwd);
|
||||||
static void ftp_return_to_previous_path (char *pwd, char *dir);
|
static void ftp_return_to_previous_path (char *pwd, char *dir);
|
||||||
|
static void ftp_reset (void);
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
DEFINE PUBLIC FUNCTIONS
|
DEFINE PUBLIC FUNCTIONS
|
||||||
@ -405,16 +406,6 @@ void ftp_disable (void) {
|
|||||||
ftp_data.state = E_FTP_STE_DISABLED;
|
ftp_data.state = E_FTP_STE_DISABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ftp_reset (void) {
|
|
||||||
// close all connections and start all over again
|
|
||||||
servers_close_socket(&ftp_data.lc_sd);
|
|
||||||
servers_close_socket(&ftp_data.ld_sd);
|
|
||||||
ftp_close_cmd_data();
|
|
||||||
ftp_data.state = E_FTP_STE_START;
|
|
||||||
ftp_data.substate.data = E_FTP_STE_SUB_DISCONNECTED;
|
|
||||||
SOCKETFIFO_Flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
DEFINE PRIVATE FUNCTIONS
|
DEFINE PRIVATE FUNCTIONS
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
@ -1055,3 +1046,13 @@ static void ftp_return_to_previous_path (char *pwd, char *dir) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ftp_reset (void) {
|
||||||
|
// close all connections and start all over again
|
||||||
|
servers_close_socket(&ftp_data.lc_sd);
|
||||||
|
servers_close_socket(&ftp_data.ld_sd);
|
||||||
|
ftp_close_cmd_data();
|
||||||
|
ftp_data.state = E_FTP_STE_START;
|
||||||
|
ftp_data.substate.data = E_FTP_STE_SUB_DISCONNECTED;
|
||||||
|
SOCKETFIFO_Flush();
|
||||||
|
}
|
||||||
|
@ -34,6 +34,5 @@ extern void ftp_init (void);
|
|||||||
extern void ftp_run (void);
|
extern void ftp_run (void);
|
||||||
extern void ftp_enable (void);
|
extern void ftp_enable (void);
|
||||||
extern void ftp_disable (void);
|
extern void ftp_disable (void);
|
||||||
extern void ftp_reset (void);
|
|
||||||
|
|
||||||
#endif /* FTP_H_ */
|
#endif /* FTP_H_ */
|
||||||
|
@ -93,7 +93,6 @@ typedef struct _wlan_obj_t {
|
|||||||
uint8_t mac[SL_MAC_ADDR_LEN];
|
uint8_t mac[SL_MAC_ADDR_LEN];
|
||||||
uint8_t ssid[33];
|
uint8_t ssid[33];
|
||||||
uint8_t bssid[6];
|
uint8_t bssid[6];
|
||||||
volatile uint8_t stasconnected;
|
|
||||||
|
|
||||||
} wlan_obj_t;
|
} wlan_obj_t;
|
||||||
|
|
||||||
@ -163,7 +162,6 @@ STATIC wlan_obj_t wlan_obj = {
|
|||||||
.ssid = {0},
|
.ssid = {0},
|
||||||
.bssid = {0},
|
.bssid = {0},
|
||||||
.mac = {0},
|
.mac = {0},
|
||||||
.stasconnected = 0,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
STATIC const mp_cb_methods_t wlan_cb_methods;
|
STATIC const mp_cb_methods_t wlan_cb_methods;
|
||||||
@ -222,16 +220,10 @@ void SimpleLinkWlanEventHandler(SlWlanEvent_t *pWlanEvent)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SL_WLAN_STA_CONNECTED_EVENT:
|
case SL_WLAN_STA_CONNECTED_EVENT:
|
||||||
wlan_obj.stasconnected++;
|
// TODO
|
||||||
break;
|
break;
|
||||||
case SL_WLAN_STA_DISCONNECTED_EVENT:
|
case SL_WLAN_STA_DISCONNECTED_EVENT:
|
||||||
if (wlan_obj.stasconnected > 0) {
|
// TODO
|
||||||
if (--wlan_obj.stasconnected == 0) {
|
|
||||||
#if (MICROPY_PORT_HAS_TELNET || MICROPY_PORT_HAS_FTP)
|
|
||||||
servers_reset();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case SL_WLAN_P2P_DEV_FOUND_EVENT:
|
case SL_WLAN_P2P_DEV_FOUND_EVENT:
|
||||||
// TODO
|
// TODO
|
||||||
|
@ -83,8 +83,8 @@ typedef struct {
|
|||||||
DEFINE PUBLIC FUNCTIONS
|
DEFINE PUBLIC FUNCTIONS
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
STATIC void pybadc_init (pyb_adc_obj_t *self) {
|
STATIC void pybadc_init (pyb_adc_obj_t *self) {
|
||||||
// enable the ADC channel
|
// enable the ADC channel
|
||||||
MAP_ADCChannelEnable(ADC_BASE, self->channel);
|
MAP_ADCChannelEnable(ADC_BASE, self->channel);
|
||||||
// enable and configure the timer
|
// enable and configure the timer
|
||||||
MAP_ADCTimerConfig(ADC_BASE, (1 << 17) - 1);
|
MAP_ADCTimerConfig(ADC_BASE, (1 << 17) - 1);
|
||||||
MAP_ADCTimerEnable(ADC_BASE);
|
MAP_ADCTimerEnable(ADC_BASE);
|
||||||
|
@ -54,13 +54,12 @@ typedef struct {
|
|||||||
volatile bool enabled;
|
volatile bool enabled;
|
||||||
volatile bool do_disable;
|
volatile bool do_disable;
|
||||||
volatile bool do_enable;
|
volatile bool do_enable;
|
||||||
volatile bool do_reset;
|
|
||||||
}servers_Data_t;
|
}servers_Data_t;
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
DECLARE PRIVATE DATA
|
DECLARE PRIVATE DATA
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
static servers_Data_t servers_data = {.enabled = false, .do_disable = false, .do_enable = false, .do_reset = false};
|
static servers_Data_t servers_data = {.enabled = false, .do_disable = false, .do_enable = false};
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
DECLARE PRIVATE FUNCTIONS
|
DECLARE PRIVATE FUNCTIONS
|
||||||
@ -96,16 +95,8 @@ void TASK_Servers (void *pvParameters) {
|
|||||||
ftp_disable();
|
ftp_disable();
|
||||||
// now clear the flags
|
// now clear the flags
|
||||||
servers_data.do_disable = false;
|
servers_data.do_disable = false;
|
||||||
servers_data.do_reset = false;
|
|
||||||
servers_data.enabled = false;
|
servers_data.enabled = false;
|
||||||
}
|
}
|
||||||
else if (servers_data.do_reset) {
|
|
||||||
// reset network services
|
|
||||||
telnet_reset();
|
|
||||||
ftp_reset();
|
|
||||||
// clear the flag
|
|
||||||
servers_data.do_reset = false;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
if (cycle) {
|
if (cycle) {
|
||||||
telnet_run();
|
telnet_run();
|
||||||
@ -135,11 +126,6 @@ void TASK_Servers (void *pvParameters) {
|
|||||||
void servers_start (void) {
|
void servers_start (void) {
|
||||||
servers_data.do_disable = false;
|
servers_data.do_disable = false;
|
||||||
servers_data.do_enable = true;
|
servers_data.do_enable = true;
|
||||||
servers_data.do_reset = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void servers_reset (void) {
|
|
||||||
servers_data.do_reset = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void servers_stop (void) {
|
void servers_stop (void) {
|
||||||
@ -148,8 +134,6 @@ void servers_stop (void) {
|
|||||||
do {
|
do {
|
||||||
HAL_Delay (SERVERS_CYCLE_TIME_MS);
|
HAL_Delay (SERVERS_CYCLE_TIME_MS);
|
||||||
} while (servers_are_enabled());
|
} while (servers_are_enabled());
|
||||||
// clear the last command line
|
|
||||||
telnet_reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool servers_are_enabled (void) {
|
bool servers_are_enabled (void) {
|
||||||
|
@ -61,7 +61,6 @@ extern char *servers_pass;
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
extern void TASK_Servers (void *pvParameters);
|
extern void TASK_Servers (void *pvParameters);
|
||||||
extern void servers_start (void);
|
extern void servers_start (void);
|
||||||
extern void servers_reset (void);
|
|
||||||
extern void servers_stop (void);
|
extern void servers_stop (void);
|
||||||
extern bool servers_are_enabled (void);
|
extern bool servers_are_enabled (void);
|
||||||
extern void servers_close_socket (int16_t *sd);
|
extern void servers_close_socket (int16_t *sd);
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
#define TELNET_TX_RETRIES_MAX 25
|
#define TELNET_TX_RETRIES_MAX 25
|
||||||
#define TELNET_WAIT_TIME_MS 5
|
#define TELNET_WAIT_TIME_MS 5
|
||||||
#define TELNET_LOGIN_RETRIES_MAX 3
|
#define TELNET_LOGIN_RETRIES_MAX 3
|
||||||
#define TELNET_TIMEOUT_MS 1800000 // 30 minutes
|
#define TELNET_TIMEOUT_MS 300000 // 5 minutes
|
||||||
#define TELNET_CYCLE_TIME_MS (SERVERS_CYCLE_TIME_MS * 2)
|
#define TELNET_CYCLE_TIME_MS (SERVERS_CYCLE_TIME_MS * 2)
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@ -131,6 +131,7 @@ static telnet_result_t telnet_recv_text_non_blocking (void *buff, _i16 Maxlen, _
|
|||||||
static void telnet_process (void);
|
static void telnet_process (void);
|
||||||
static void telnet_parse_input (uint8_t *str, int16_t *len);
|
static void telnet_parse_input (uint8_t *str, int16_t *len);
|
||||||
static bool telnet_send_with_retries (int16_t sd, const void *pBuf, int16_t len);
|
static bool telnet_send_with_retries (int16_t sd, const void *pBuf, int16_t len);
|
||||||
|
static void telnet_reset (void);
|
||||||
static void telnet_reset_buffer (void);
|
static void telnet_reset_buffer (void);
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@ -290,13 +291,6 @@ void telnet_disable (void) {
|
|||||||
telnet_data.state = E_TELNET_STE_DISABLED;
|
telnet_data.state = E_TELNET_STE_DISABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
void telnet_reset (void) {
|
|
||||||
// close the connection and start all over again
|
|
||||||
servers_close_socket(&telnet_data.n_sd);
|
|
||||||
servers_close_socket(&telnet_data.sd);
|
|
||||||
telnet_data.state = E_TELNET_STE_START;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool telnet_is_enabled (void) {
|
bool telnet_is_enabled (void) {
|
||||||
return telnet_data.enabled;
|
return telnet_data.enabled;
|
||||||
}
|
}
|
||||||
@ -476,6 +470,13 @@ static bool telnet_send_with_retries (int16_t sd, const void *pBuf, int16_t len)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void telnet_reset (void) {
|
||||||
|
// close the connection and start all over again
|
||||||
|
servers_close_socket(&telnet_data.n_sd);
|
||||||
|
servers_close_socket(&telnet_data.sd);
|
||||||
|
telnet_data.state = E_TELNET_STE_START;
|
||||||
|
}
|
||||||
|
|
||||||
static void telnet_reset_buffer (void) {
|
static void telnet_reset_buffer (void) {
|
||||||
memset (telnet_data.rxBuffer, '\b', TELNET_RX_BUFFER_SIZE / 2);
|
memset (telnet_data.rxBuffer, '\b', TELNET_RX_BUFFER_SIZE / 2);
|
||||||
telnet_data.rxWindex = TELNET_RX_BUFFER_SIZE / 2;
|
telnet_data.rxWindex = TELNET_RX_BUFFER_SIZE / 2;
|
||||||
|
@ -38,7 +38,6 @@ extern bool telnet_rx_any (void);
|
|||||||
extern int telnet_rx_char (void);
|
extern int telnet_rx_char (void);
|
||||||
extern void telnet_enable (void);
|
extern void telnet_enable (void);
|
||||||
extern void telnet_disable (void);
|
extern void telnet_disable (void);
|
||||||
extern void telnet_reset (void);
|
|
||||||
extern bool telnet_is_enabled (void);
|
extern bool telnet_is_enabled (void);
|
||||||
extern bool telnet_is_active (void);
|
extern bool telnet_is_active (void);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user