private void ConnectedPeripheral(object sender, CBPeripheralEventArgs e) { var deviceId = Device.DeviceIdentifierToGuid(e.Peripheral.Identifier); if (ConnectedDevices.All(x => x.Id != deviceId)) { var device = new Device(e.Peripheral); ConnectedDevices.Add(device); DeviceConnected(this, new DeviceConnectionEventArgs(device)); } }
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); }
private void DiscoveredPeripheral(object sender, CBDiscoveredPeripheralEventArgs e) { var deviceId = Device.DeviceIdentifierToGuid(e.Peripheral.Identifier); if (DiscoveredDevices.All(x => x.Id != deviceId)) { var device = new Device(e.Peripheral); DiscoveredDevices.Add(device); DeviceDiscovered(this, new DeviceDiscoveredEventArgs(device)); } }