public void ConnectThread() { lock (sync) { try { if (BTClient == null) { BTClient = new BluetoothClient(); } BTClient.Connect(BTEndPoint); this.BTStream = BTClient.GetStream(); this.NXT = new NXTProtocol(this.BTStream, NXTStreamType.STREAM_SOCKET); this.NXT.batteryLevelDelegate = BatteryLevel; this.NXT.getVersionDelegate = Version; this.NXT.lsReadDelegate = LSRead; this.NXT.lsGetStatusDelegate = LSGetStatus; this.NXT.keepAliveDelegate = KeepAlive; this.IsConnected = true; Program.form1.Invoke(connectedDelegate); } catch (Exception e) { this.IsConnected = false; this.Log("Failed to connect to " + this.DeviceName + ":"); this.Log("-- " + e.Message); } } }
/// <summary> /// Initializes a new instance of the DataManagementViewModel class. /// </summary> public DataManagementViewModel() { Bluetooth = new BTClient("C:/Users/Andrew/Documents/Team 20/2019-20/Scouting/Data/"); ReceiveFileCommand = new ReceiveFileCommand(this); CancelCommand = new CancelCommand(this); MergeCommand = new MergeCommand(this); }
public MainPage() { this.InitializeComponent(); btClient = new BTClient(this); btClient.InitializeCompleted += Sender_InitializeCompleted; btClient.MessageRecieved += BtClient_MessageRecieved; viewModel = new MainPageViewModel(); viewModel.DeviceInfoCollection = btClient.DeviceInfoCollection; }
public MainPage() { this.InitializeComponent(); mediaActionPlayer = null; btClient = new BTClient(this); btClient.InitializeCompleted += Sender_InitializeCompleted; btClient.MessageRecieved += BtClient_MessageRecieved; sceneData = new SceneData(); }
public bool Disconnect() { try { BTClient.Close(); this.IsConnected = false; this.Log("Disconnected from " + this.DeviceName); } catch (Exception e) { this.IsConnected = false; this.Log("Error disconnecting from " + this.DeviceName + ":"); this.Log("-- " + e.Message); } return(this.IsConnected); }