public MainPage() { this.InitializeComponent(); if( useBluetooth ) { /* * I've written my bluetooth device name as a parameter to the BluetoothSerial constructor. You should change this to your previously-paired * device name if using Bluetooth. You can also use the BluetoothSerial.listAvailableDevicesAsync() function to list * available devices, but that is not covered in this sample. */ bluetooth = new BluetoothSerial( "RNBT-E072" ); arduino = new RemoteDevice( bluetooth ); bluetooth.ConnectionEstablished += OnConnectionEstablished; //these parameters don't matter for bluetooth bluetooth.begin( 0, 0 ); } else { /* * I've written my Arduino device VID and PID as a parameter to the BluetoothSerial constructor. You should change this to your * device VID and PID if using USB. You can also use the UsbSerial.listAvailableDevicesAsync() function to list * available devices, but that is not covered in this sample. */ usb = new UsbSerial( "VID_2341", "PID_0043" ); //I've written in my device D directly arduino = new RemoteDevice( usb ); usb.ConnectionEstablished += OnConnectionEstablished; //SerialConfig.8N1 is the default config for Arduino devices over USB usb.begin( 115200, SerialConfig.SERIAL_8N1 ); } }
private void MainPage_Loaded(object sender, RoutedEventArgs e) { var connection = new BluetoothSerial("RNBT-A297"); _arduino = new RemoteDevice(connection); connection.ConnectionEstablished += Connection_ConnectionEstablished; connection.begin(0, 0); }
public MainPage() { this.InitializeComponent(); if (useBluetooth) { /* * I've written my bluetooth device name as a parameter to the BluetoothSerial constructor. You should change this to your previously-paired * device name if using Bluetooth. You can also use the BluetoothSerial.listAvailableDevicesAsync() function to list * available devices, but that is not covered in this sample. */ bluetooth = new BluetoothSerial("RNBT-E072"); arduino = new RemoteDevice(bluetooth); bluetooth.ConnectionEstablished += OnConnectionEstablished; //these parameters don't matter for bluetooth bluetooth.begin(0, 0); } else { /* * I've written my Arduino device VID and PID as a parameter to the BluetoothSerial constructor. You should change this to your * device VID and PID if using USB. You can also use the UsbSerial.listAvailableDevicesAsync() function to list * available devices, but that is not covered in this sample. */ usb = new UsbSerial("VID_2341", "PID_0043"); //I've written in my device D directly arduino = new RemoteDevice(usb); usb.ConnectionEstablished += OnConnectionEstablished; //SerialConfig.8N1 is the default config for Arduino devices over USB usb.begin(115200, SerialConfig.SERIAL_8N1); } }
private void InitWRA() { connection = new BluetoothSerial("Dev B"); // HC-06 arduino = new RemoteDevice(connection); connection.ConnectionEstablished += Connection_ConnectionEstablished; connection.ConnectionFailed += Connection_ConnectionFailed; connection.ConnectionLost += Connection_ConnectionLost; connection.begin(9600, 0); }
/// <summary> /// Connect to arduino over bloetooth /// </summary> /// <param name="DeviceID">Device name or ID</param> /// <returns></returns> public static ArduinoController BluetoothConnection(string DeviceID, uint baudRate = 115200, SerialConfig serialConfig = SerialConfig.SERIAL_8N1) { BluetoothSerial Connection1 = new BluetoothSerial(DeviceID); var res = new ArduinoController(Connection1); Connection1.begin(baudRate, serialConfig); res.bluetoothConnection = Connection1; res._connType = ConnectionType.Bluetooth; return(res); }
private void ConnectButton_Click(object sender, RoutedEventArgs e) { //these parameters don't matter for bluetooth- Arduino Firmata, except SerialConfig.SERIAL_8N1 bluetooth.begin(115200, SerialConfig.SERIAL_8N1); this.ConnectButton.IsEnabled = false; //Connecting BT so show progress ring this.progress1.IsActive = true; this.progress1.Visibility = Visibility.Visible; }
public PinControl(string btName, uint BaudRate) { BTConnection = new BluetoothSerial("FixHelp"); baudRate = BaudRate; isBtAvailable = false; arduino = new RemoteDevice(BTConnection); BTConnection.begin(baudRate, SerialConfig.SERIAL_8N1); isBtAvailable = BTConnection.connectionReady(); }
public async Task Setup() { await ExecuteOnMainThread(() => _checkConnectiontimer.Stop()); IsReady = false; await Task.Delay(2000); ConnectionNotify?.Invoke(this, "Tentando se Conectar"); await Task.Delay(2000); if (_bluetoothSerial != null) { Arduino?.Dispose(); Arduino = new RemoteDevice(_bluetoothSerial); await Task.Delay(1000); await ExecuteOnMainThread(() => _bluetoothSerial.begin(57600, SerialConfig.SERIAL_8N1)); } else { Arduino?.Dispose(); Arduino = new RemoteDevice(_usbSerial); await Task.Delay(1000); await ExecuteOnMainThread(() => _usbSerial.begin(57600, SerialConfig.SERIAL_8N1)); } SerialOut = new SerialOutController(Arduino, 12, 8, 7); Arduino.DeviceConnectionLost += message => { ConnectionNotify?.Invoke(this, "Conexão Arduino Perdida: " + message); }; Arduino.DeviceConnectionFailed += async message => { ConnectionNotify?.Invoke(this, "Conexão Arduino Falhou: " + message); await Task.Delay(5000); }; Arduino.DeviceReady += async() => await ArduinoOnDeviceReady(); Servos = new Dictionary <ETinBotServo, ServoController>() { [ETinBotServo.ServoHand] = new ServoController(Arduino, 09), [ETinBotServo.ServoHeadX] = new ServoController(Arduino, 05), [ETinBotServo.ServoHeadY] = new ServoController(Arduino, 06), [ETinBotServo.ServoLeftArm] = new ServoController(Arduino, 03, true), [ETinBotServo.ServoRightArm] = new ServoController(Arduino, 11), [ETinBotServo.ServoTorso] = new ServoController(Arduino, 10) }; await ExecuteOnMainThread(() => _checkConnectiontimer.Start()); }
public async Task CaptureReadings() { await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { this.bluetooth = new BluetoothSerial("RNBT-9E86"); this.firmata = new UwpFirmata(); this.firmata.FirmataConnectionReady += Firmata_FirmataConnectionReady; this.firmata.StringMessageReceived += Firmata_StringMessageReceived; this.device = new RemoteDevice(firmata); this.firmata.begin(bluetooth); bluetooth.begin(9600, SerialConfig.SERIAL_8N1); }); }
private async void connect() { dt = new DispatcherTimer() { Interval = new TimeSpan(500) }; var dev = await BluetoothSerial.listAvailableDevicesAsync(); foreach (var x in dev) { System.Diagnostics.Debug.WriteLine("Found " + x.Name); } bluetoothcomm = new BluetoothSerial(dev[0]); arduino = new RemoteDevice(bluetoothcomm); bluetoothcomm.ConnectionEstablished+= Comm_ConnectionEstablished; bluetoothcomm.begin(57600, SerialConfig.SERIAL_8N1); }
public MainPage() { this.InitializeComponent(); Connection = new BluetoothSerial("RN42-D924"); Arduino = new RemoteDevice(Connection); DataContext = this; Connection.ConnectionEstablished += Connection_ConnectionEstablished; IsConnected = false; Connection.begin(115200, SerialConfig.SERIAL_8N1); }
private void btnStart_Click(object sender, RoutedEventArgs e) { //_bluetooth = new BluetoothSerial("HC-05"); _bluetooth = new BluetoothSerial("sowaphone"); _arduino = new RemoteDevice(_bluetooth); _bluetooth.ConnectionLost += _bluetooth_ConnectionLost; _bluetooth.ConnectionFailed += _bluetooth_ConnectionFailed; _bluetooth.ConnectionEstablished += OnConnectionEstablished; _bluetooth.begin(0, SerialConfig.SERIAL_8N1); }
public MainPage() { this.InitializeComponent(); /* * I've written my bluetooth device name as a parameter to the BluetoothSerial constructor. You should change this to your previously-paired * device name if using Bluetooth. You can also use the BluetoothSerial.listAvailableDevicesAsync() function to list * available devices, but that is not covered in this sample. */ bluetooth = new BluetoothSerial( "RNBT-E072" ); arduino = new RemoteDevice( bluetooth ); bluetooth.ConnectionEstablished += OnConnectionEstablished; //these parameters don't matter for bluetooth bluetooth.begin( 115200, SerialConfig.SERIAL_8N1 ); }
public MainPage() { this.InitializeComponent(); /* * I've written my bluetooth device name as a parameter to the BluetoothSerial constructor. You should change this to your previously-paired * device name if using Bluetooth. You can also use the BluetoothSerial.listAvailableDevicesAsync() function to list * available devices, but that is not covered in this sample. */ bluetooth = new BluetoothSerial("RNBT-E072"); arduino = new RemoteDevice(bluetooth); bluetooth.ConnectionEstablished += OnConnectionEstablished; //these parameters don't matter for bluetooth bluetooth.begin(115200, SerialConfig.SERIAL_8N1); }