private void InitialSetupOnClick(object sender, EventArgs e)
 {
     using (InitialSetupPage isp = new InitialSetupPage(bluetoothServer, devices))
     {
         Dictionary <string, string> pairedDevice;
         if (isp.ShowDialog() == DialogResult.OK)
         {
             bluetoothServer.ResetProtocolStack();
             MessageProcessor.InitialSetup = true;
             AddNewDevice("master-device5", "");
             System.Threading.Thread.Sleep(20000);
             if (MessageProcessor.State.Equals(ProtocolState.GotSecret))
             {
                 initialSetupButton.Enabled = false;
                 MessageBox.Show("¯\\_(ツ)_/¯");
             }
             pairedDevice = isp.Devices;
             devices      = pairedDevice;
             initialSetupButton.Enabled = false;
         }
         MessageProcessor.InitialSetup = false;
         bluetoothServer.ResetProtocolStack();
         isp.Dispose();
     }
 }
        private void StartPairingButton_Click(object sender, EventArgs e)
        {
            string deviceName = newTrustedDeviceTextBox.Text;

            if (startPairingButton.Text.Equals("Start Pairing"))
            {
                if (MessageProcessor.State.Equals(ProtocolState.GotSecret))
                {
                    server.ResetProtocolStack();
                    RenderSecretKeyWithLease();
                }
                else
                {
                    setupNewTrustedDeviceLabel.Text = "Need to connect a trusted device to enable pairing";
                    startPairingButton.Enabled      = false;
                }
            }
            else if (startPairingButton.Text.Equals("Continue Pairing"))
            {
                RenderPublicKeyWithLease();
            }
            else if (startPairingButton.Text.Equals("Final Step"))
            {
                MessageProcessor.InitialSetup = true;
                System.Threading.Thread.Sleep(20000);
                if (MessageProcessor.State.Equals(ProtocolState.GotSecret))
                {
                    knownDevicesComboBox.Items.Add(deviceName);
                    UpdateSelectedItem();
                }
                else
                {
                    MessageBox.Show("Bluetooth pairing failed. Please try again at a later time.");
                }
                MessageProcessor.InitialSetup = false;
            }
            else
            {
                MessageBox.Show("Unexpected error... sorry for the inconvience.");
            }

            newTrustedDeviceTextBox.Text = "";
        }