void Adapter_DeviceConnected(object sender, DeviceConnectionEventArgs e) { Debug.WriteLine("Device Connected"); this.Device = e.Device; //if (this.Device.Name.Replace("PE", "").Replace("FT", "").StartsWith("932")) //{ // Debug.WriteLine("Instantiating PE932 Handler"); // this.syncDeviceHandler = SyncDeviceHandler932.GetInstance(); //} /*else */ if (this.Device.Name.Replace("PE", "").Replace("FT", "").StartsWith("961")) { Debug.WriteLine("Instantiating PE/FT961 Handler"); this.SyncDeviceHandler = SyncDeviceHandler961.GetInstance(); } else if (this.Device.Name.StartsWith("H25FE2")) { this.SyncDeviceHandler = SyncDeviceHandlerStriiv.GetInstance(); } this.SyncDeviceHandler.IncrementProgressBar += UpdateProgressBar; this.SyncDeviceHandler.SyncDone += DoneSyncing; this.SyncDeviceHandler.SetAdapter(this.Adapter); this.SyncDeviceHandler.SetDevice(this.Device); this.SyncDeviceHandler.SetWebService(this.WebService); e.Device.ServicesDiscovered += Services_Discovered; //this.Adapter.CommandResponse += SyncDeviceHandler.ReceiveResponse; e.Device.DiscoverServices(); }
public UsbHostControllerApiWrapper(NativeApi api) { this.Api = api; this.impl = api.Implementation; this.Acquire(); this.onConnectDispatcher = NativeEventDispatcher.GetDispatcher("GHIElectronics.TinyCLR.NativeEventNames.UsbHost.OnConnectionChanged"); this.onConnectDispatcher.OnInterrupt += (apiName, d0, d1, d2, d3, ts) => { if (this.Api.Name == apiName) { var id = (uint)d0; var connection = (DeviceConnectionStatus)d3; var interfaceIndex = (byte)d1; var deviceType = (DeviceType)d2; GetDeviceInformation(id, out var vendor, out var product, out var port); var deviceConnectedEventArgs = new DeviceConnectionEventArgs(id, interfaceIndex, deviceType, vendor, product, port, connection); this.onConnectionChangedCallbacks?.Invoke(null, deviceConnectedEventArgs); } }; }
void Adapter_DeviceConnected(object sender, DeviceConnectionEventArgs e) { Debug.WriteLine("Device Connected"); this.Device = e.Device; e.Device.ServicesDiscovered += Services_Discovered; e.Device.DiscoverServices(); }
public void ConnectToDevice(IDevice device) { connectedDevices.Add(device); var args = new DeviceConnectionEventArgs(); args.Device = device; DeviceConnected?.Invoke(this, args); }
public void DisconnectDevice(IDevice device) { connectedDevices.Remove(device); var args = new DeviceConnectionEventArgs(); args.Device = device; DeviceDisconnected?.Invoke(this, args); }
private void FailedToConnectPeripheral(object sender, CBPeripheralErrorEventArgs e) { var device = new Device(e.Peripheral); var args = new DeviceConnectionEventArgs(device) { ErrorMessage = e.Error.Description }; DeviceFailedToConnect(this, args); }
async void _adapter_DeviceConnected(object sender, DeviceConnectionEventArgs e) { var service = await e.Device.GetServiceAsync(Guid.Parse("ffe0ecd2-3d16-4f8d-90de-e89e7fc396a5")); _characteristic = await service.GetCharacteristicAsync(Guid.Parse("d8de624e-140f-4a22-8594-e2216b84a5f2")); _characteristic.StartUpdates(); _characteristic.ValueUpdated += _characteristic_ValueUpdated; _device = e.Device; }
private void BluetoothGatt_DeviceDisconnected(object sender, DeviceConnectionEventArgs e) { var connDevice = ConnectedDevices.FirstOrDefault(x => x.Id == e.Device.Id); if (connDevice != null) { ConnectedDevices.Remove(connDevice); } DeviceDisconnected(this, e); }
void Adapter_DeviceDisconnected(object sender, DeviceConnectionEventArgs e) { Device.BeginInvokeOnMainThread(() => { this.lblConnectedDevice.IsVisible = false; this.lblCodeCaption.IsVisible = false; this.txtCode.IsVisible = false; this.btnValidate.IsVisible = false; this.btnGenerateCode.IsVisible = false; this.btnValidate.IsEnabled = false; this.btnDisconnect.IsVisible = false; this.lblConnectedDevice.Text = ""; this.txtCode.Text = ""; }); //this.StartScanning(); this.StartScanning(0x180F.UuidFromPartial()); }
/// <summary> /// Connect to a device. /// </summary> /// <param name="device">The device.</param> public async void ConnectToDevice(IDevice device) { var peripheral = device.NativeDevice as CBPeripheral; _central.ConnectPeripheral(peripheral); await Task.Delay(ConnectionTimeout); if (ConnectedDevices.All(x => x.Id != device.Id)) { _central.CancelPeripheralConnection(peripheral); var args = new DeviceConnectionEventArgs(device) { ErrorMessage = "The device connection timed out." }; DeviceFailedToConnect(this, args); } }
void Adapter_DeviceConnected(object sender, DeviceConnectionEventArgs e) { Debug.WriteLine("Device connected"); //adapter.StopScanningForDevices(); StopScanning(); Device.BeginInvokeOnMainThread(() => { this.lblConnectedDevice.IsVisible = true; this.btnGenerateCode.IsVisible = true; this.btnDisconnect.IsVisible = true; this.lblConnectedDevice.Text = "Device Connected: " + e.Device.Name; }); Debug.WriteLine("Connected Devices Count: " + adapter.ConnectedDevices.Count); device = e.Device; device.ServicesDiscovered += Device_ServicesDiscovered; device.DiscoverServices(); }
void Adapter_DeviceDisconnected(object sender, DeviceConnectionEventArgs e) { Debug.WriteLine("SyncHandler: Device Disconnected"); this.DeviceDisconnected(this, new EventArgs() { }); this.ProcessingDevice = false; this.Device = null; e.Device.ServicesDiscovered -= Services_Discovered; if (this.SyncDeviceHandler != null) { this.SyncDeviceHandler.CleanUp(); } this.DeviceDisconnected(this, new EventArgs { }); this.Adapter.StartScanningForDevices(); }
void AdapterDeviceConnected(object sender, DeviceConnectionEventArgs e) { device = e.Device; // do we need to overwrite this? // when services are discovered device.ServicesDiscovered += (object se, EventArgs ea) => { Debug.WriteLine("device.ServicesDiscovered"); //services = (List<IService>)device.Services; if (services.Count == 0) { Device.BeginInvokeOnMainThread(() => { foreach (var service in device.Services) { services.Add(service); } }); } }; // start looking for services device.DiscoverServices(); }
void Adapter_DeviceDisconnected(object sender, DeviceConnectionEventArgs e) { }
private void AdapterOnDeviceConnected(object sender, DeviceConnectionEventArgs deviceConnectionEventArgs) { _device = deviceConnectionEventArgs.Device; ProcessConnection(); }
void DeviceDisconnected(object sender, DeviceConnectionEventArgs e) { // todo: stale }
/*void Device_ServicesDiscovered (object sender, EventArgs e) * { * Debug.WriteLine("device.ServicesDiscovered"); * //this.services = (List<IService>)device.Services; * * if (this.services.Count == 0) * { * Debug.WriteLine ("Service Count: " + device.Services.Count); * foreach (var service in device.Services) * { * service.CharacteristicsDiscovered += (object s, EventArgs ce) => { * * Debug.WriteLine("service.CharacteristicsDiscovered"); * if (this.characteristics.Count == 0) * { * Debug.WriteLine("Characteristics count: "+service.Characteristics.Count); * foreach (var characteristic in service.Characteristics) * { * if(characteristic !=null) * { * if(characteristic.Uuid.ToUpper().Contains("2A24") || * characteristic.Uuid.ToUpper().Contains("2A25") || * characteristic.Uuid.ToUpper().Contains("2A26") || * characteristic.Uuid.ToUpper().Contains("2A19") ) * { * if(characteristic.CanRead) * { * characteristic.ValueUpdated += (cs, chre) => { * Debug.WriteLine("characteristic.ValueUpdated"); * }; * characteristic.ReadAsync(); * } * } * else if(characteristic.Uuid.ToUpper().Contains("FF07")) * { * Debug.WriteLine("FF07"); * if(characteristic.CanUpdate) * { * this.ff07Char = characteristic; * * characteristic.StartUpdates(); * } * } * else if(characteristic.Uuid.ToUpper().Contains("FF08")) * { * Debug.WriteLine("FF08"); * if(characteristic.CanUpdate) * { * this.ff08Char = characteristic; * * characteristic.StartUpdates(); * } * } * } * } * } * }; * * service.DiscoverCharacteristics (); * } * } * }*/ void Adapter_DeviceFailedToConnect(object sender, DeviceConnectionEventArgs e) { StartScanning(); }
void Adapter_DeviceFailedToConnect(object sender, DeviceConnectionEventArgs e) { }
void DeviceConnected(object sender, DeviceConnectionEventArgs e) { Navigation.PushAsync(new DevicePage(e.Device)); }
private void BluetoothGatt_DeviceConnected(object sender, DeviceConnectionEventArgs e) { ConnectedDevices.Add(e.Device); DeviceConnected(this, e); }
private static void UsbHostController_OnConnectionChangedEvent(UsbHostController sender, DeviceConnectionEventArgs e) { if (e.DeviceStatus == DeviceConnectionStatus.Connected) { usbConnected = true; } else { usbConnected = false; } }
private void BluetoothGatt_DeviceDisconnected(object sender, DeviceConnectionEventArgs e) { DeviceDisconnected(this, e); }