private void buttonStart_Click(object sender, EventArgs e) { if (checkBoxUsb.Checked) { _wasps = new WaspCollection(Handle); } else { _wasps = new WaspCollection(); } _wasps.CollectionChanged += Wasps_CollectionChanged; // connect to ANT device notifications _sensors = new AntPlusDevices(_wasps); _sensors.AntPlusDeviceEvent += NewSensors_AntPlusDeviceEvent;; buttonStart.Enabled = false; }
/// <summary> /// Connect to Wasp /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Click(object sender, RoutedEventArgs e) { try { if (UsbOnly.IsChecked == true) { WindowInteropHelper w = new WindowInteropHelper(this); _wasps = new WaspCollection(w.Handle); } else { _wasps = new WaspCollection(); } // Register for notification of a new WASP added or removed _wasps.CollectionChanged += WASP_CollectionChangedEvent; // Extract the list of ANT devices reported by the WASPs _ants = new AntPlusDevices(_wasps); // Get the list of KeiserM3i bikes _bikes = _ants.KeiserM3Bikes; // Register for notification of a bike added or removed _bikes.BluetoothNewDeviceEvent += new EventHandler <KeiserM3EventArgs>(Keiser_DataEvent); _polarHrms = _ants.PolarH7HeartRateMonitors; _polarHrms.CollectionChanged += PolarHrms_CollectionChanged; _suuntoHRMs = _ants.SuuntoHeartRateMonitors; _suuntoHRMs.CollectionChanged += Suunto_CollectionChanged; _ble = _ants.GenericBleDevices; _ble.BluetoothNewDeviceEvent += Ble_BluetoothNewDeviceEvent; BtnConnect.IsEnabled = false; } catch (Exception ex) { MessageBox.Show(string.Format("Failed to connect: {0}", ex.ToString())); } }
/// <summary> /// Creates a WASP collection which will then accept data from BLE and ANT devices /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void StartButton_Click(object sender, RoutedEventArgs e) { // Create a collection of wasps on all available networks if (checkBoxUsb.IsChecked == true) { WindowInteropHelper w = new WindowInteropHelper(this); _wasps = new WaspCollection(WaspCollection.DefaultMulticastPort, w.Handle); } else { _wasps = new WaspCollection(); } _wasps.CollectionVerbosity = Wasp.WaspLogLevel.All; // Get Query response message _wasps.CollectionChanged += wasps_CollectionChanged; // Extract the list of ANT devices reported by the WASPs _ants = new AntPlusDevices(_wasps); _ants.AntPlusDeviceEvent += _ants_AntPlusDeviceEvent; _ants.KeiserM3Bikes.BluetoothNewDeviceEvent += KeiserM3Bikes_BluetoothNewDeviceEvent; StartButton.IsEnabled = false; }