|
@@ -34,6 +34,9 @@
|
|
|
/* Repeat Login timeout, 1 seconds */
|
|
|
#define REPEAT_SENSOR_INFO_TIME configTICK_RATE_HZ*1*1
|
|
|
|
|
|
+/* Set option to drop old connection if the new one is accepted */
|
|
|
+#define TCP_DROP_PREV_CONNECTION 1
|
|
|
+
|
|
|
static portBASE_TYPE FreeRTOS_CLIAuthProcess( const int8_t * const pcCommandInput, int8_t * pcWriteBuffer );
|
|
|
static portBASE_TYPE FreeRTOS_ChangePWDProcess( const int8_t * const pcCommandInput, int8_t * pcWriteBuffer );
|
|
|
void SensorInfoTimerCallback(TimerHandle_t pxTimer);
|
|
@@ -148,6 +151,7 @@ void vBasicSocketsCommandInterpreterTask( void *pvParameters )
|
|
|
struct sockaddr_in sa_temp;
|
|
|
socklen_t len;
|
|
|
#endif
|
|
|
+ static int active_sd = -1;
|
|
|
|
|
|
FD_ZERO(&master_set);
|
|
|
|
|
@@ -261,17 +265,33 @@ void vBasicSocketsCommandInterpreterTask( void *pvParameters )
|
|
|
FD_SET(new_sd, &master_set);
|
|
|
if (new_sd > max_sd) {
|
|
|
max_sd = new_sd;
|
|
|
+ }
|
|
|
#ifdef HARDWARE_BT6708
|
|
|
- lwip_getpeername(new_sd, &sa_temp, &len);
|
|
|
- flagWhiteListTelnet = white_list_check(sa_temp.sin_addr.s_addr);
|
|
|
+ lwip_getpeername(new_sd, &sa_temp, &len);
|
|
|
+ flagWhiteListTelnet = white_list_check(sa_temp.sin_addr.s_addr);
|
|
|
+#endif
|
|
|
+ recv( new_sd, cInputString, 27, 0 );
|
|
|
+ telnetState = TELNET_AUTH;
|
|
|
+ send( new_sd, pcWelcomeMessage, strlen( ( const char * ) pcWelcomeMessage ), 0 );
|
|
|
+
|
|
|
+ cInputIndex = 0;
|
|
|
+ memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );
|
|
|
+#if TCP_DROP_PREV_CONNECTION
|
|
|
+ /* Close previous active connection */
|
|
|
+ if (active_sd != -1 && active_sd != new_sd) {
|
|
|
+ DBG printf(" Close prev active connection %d\n", active_sd);
|
|
|
+ close(active_sd);
|
|
|
+ FD_CLR(active_sd, &master_set);
|
|
|
+ if (active_sd == max_sd) {
|
|
|
+ while (FD_ISSET(max_sd, &master_set) == false) {
|
|
|
+ max_sd -= 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /* Mark new connection as active */
|
|
|
+ active_sd = new_sd;
|
|
|
+ DBG printf(" New active connection %d\n", active_sd);
|
|
|
#endif
|
|
|
- recv( new_sd, cInputString, 27, 0 );
|
|
|
- telnetState = TELNET_AUTH;
|
|
|
- send( new_sd, pcWelcomeMessage, strlen( ( const char * ) pcWelcomeMessage ), 0 );
|
|
|
-
|
|
|
- cInputIndex = 0;
|
|
|
- memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );
|
|
|
- }
|
|
|
|
|
|
/* Loop back up and accept another incoming */
|
|
|
/* connection */
|