From: chleun.moon Date: Wed, 23 May 2018 06:05:05 +0000 (+0900) Subject: [Network][Non-ACR] Try to connect to Wi-Fi again X-Git-Tag: public_m1_final~10^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=af84f176e7c295b7bccdfab39db7b9e3b0d31858;p=test%2Ftct%2Fcsharp%2Fapi.git [Network][Non-ACR] Try to connect to Wi-Fi again Change-Id: I8cf14aa75d2f8cf0a338c4267caa535e11edc607 Signed-off-by: Cheoleun Moon --- diff --git a/tct-suite-vs/Tizen.Network.Tests/testcase/support/networkSetup.cs b/tct-suite-vs/Tizen.Network.Tests/testcase/support/networkSetup.cs index 7824d94..b07c390 100644 --- a/tct-suite-vs/Tizen.Network.Tests/testcase/support/networkSetup.cs +++ b/tct-suite-vs/Tizen.Network.Tests/testcase/support/networkSetup.cs @@ -16,7 +16,8 @@ namespace networkUtils public class networkSetup { public static networkSetup mInstance = new networkSetup(); - private static int MAX_TRY = 12; + private static int MAX_SCAN_TRY = 12; + private static int MAX_CONNECT_TRY = 3; private networkSetup() { @@ -89,7 +90,8 @@ namespace networkUtils ap = WiFiManager.GetConnectedAP(); } - for (int i = 0; i < MAX_TRY; i++) { + int connectTry = 0; + for (int i = 0; i < MAX_SCAN_TRY; i++) { var list = WiFiManager.GetFoundAPs(); Tizen.Log.Info(Globals.LogTag, "Get Scan List. Try: " + i); @@ -103,9 +105,32 @@ namespace networkUtils Tizen.Log.Info(Globals.LogTag, "Set passphrase"); item.SecurityInformation.SetPassphrase(WiFiPass); } - await item.ConnectAsync(); - Tizen.Log.Info(Globals.LogTag, "Connected"); - return; + try + { + await item.ConnectAsync(); + Tizen.Log.Info(Globals.LogTag, "Connected"); + return; + } + catch (System.Exception e) + { + /* + * It is possible that ConnectAsync is failed due to some network environment issue. + * In this case, we will try to connect the AP again. + */ + if (connectTry == MAX_CONNECT_TRY) + { + Tizen.Log.Info(Globals.LogTag, "Failed to connect"); + throw e; + } + else + { + connectTry++; + Tizen.Log.Info(Globals.LogTag, "Failed to connect --> try again after 3 seconds"); + await Task.Delay(3000); + break; + } + + } } } if (i == 3) @@ -114,7 +139,7 @@ namespace networkUtils await WiFiManager.ScanAsync(); } await Task.Delay(10000); - } // for (int i = 0; i < MAX_TRY; i++) { + } // for (int i = 0; i < MAX_SCAN_TRY; i++) { } // if (ap != null && ap.NetworkInformation.Essid != WiFiName) } // WiFiActivate() }