private void ConnectButton_Click(object sender, EventArgs e) { Button button = (Button)sender; if (button.Text.Equals("Connect")) { this.openConnection = connectionManager.GetConnectionContext(selectedConnection); if (openConnection.OpenConnection()) { //check authorization string userPassword = null; //TODO: Figure out if API will close socket or not. while (!openConnection.Authorize()) { //prompt user for correct password userPassword = Dialog.ShowPrompt("Password Please:", selectedConnection.Password); selectedConnection.Password = userPassword; openConnection.connection = selectedConnection; connectionManager.Save(selectedConnection); if (userPassword.Equals("")) { return; } } //TODO: Refactor maybe button.Text = "Disconnect"; //Accelerations.StartPolling(openConnection); setConnectionListItemDisplayConnected(true); //start mesh if controller available if (SelectedController != null && ControllerManager.IsControllerConnected(SelectedController)) { InitiateMesh(); } } else { Dialog.ShowMessageDialog("Error Opening Connection to ROV. Most likely Connection Refused."); } } else { StopMesh(); Accelerations.StopPolling(); openConnection.Close(); button.Text = "Connect"; //TODO: Refactor setConnectionListItemDisplayConnected(false); } }
public static void TestClassinitialize(TestContext context) { var manager = new ConnectionManager(); var connectionInfo = new ArduinoConnection() { IpAddress = "192.168.1.146", Port = 1740, Password = "******", ConnectionClass = "ThrusterLayout2Connection" }; connection = manager.GetConnectionContext(connectionInfo); connection.OpenConnection(); connection.Authorize(); }