public static DeviceIdentifierToGuid ( NSUuid id ) : System.Guid | ||
id | NSUuid | The device identifier as a NSUuid. |
return | System.Guid |
private void DisconnectedPeripheral(object sender, CBPeripheralErrorEventArgs e) { var deviceId = Device.DeviceIdentifierToGuid(e.Peripheral.Identifier); //var device = _devices.FirstOrDefault (x => x.Id == deviceId); var device = new Device(e.Peripheral); DeviceDisconnected(this, new DeviceConnectionEventArgs(device)); }
private void DisconnectedPeripheral(object sender, CBPeripheralErrorEventArgs e) { var deviceId = Device.DeviceIdentifierToGuid(e.Peripheral.Identifier); var connectedDevice = ConnectedDevices.FirstOrDefault(x => x.Id == deviceId); if (connectedDevice != null) { ConnectedDevices.Remove(connectedDevice); DeviceDisconnected(this, new DeviceConnectionEventArgs(connectedDevice)); } }
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 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)); } }
/// <summary> /// Gets the discovered devices. /// </summary> /// <value>The discovered devices.</value> //public IList<IDevice> DiscoveredDevices { // get { return _devices.ToList(); } //} /// <summary> /// Gets the connected devices. /// </summary> /// <value>The connected devices.</value> //public IList<IDevice> ConnectedDevices { // get { // return _devices.Where(x => x.State == DeviceState.Connected).ToList(); // } //} #endregion #region CBCentralManager delegate methods private void DiscoveredPeripheral(object sender, CBDiscoveredPeripheralEventArgs e) { var deviceId = Device.DeviceIdentifierToGuid(e.Peripheral.Identifier); if (_discoveringDevices.All(x => x.Id != deviceId)) { var device = new Device(e.Peripheral, e.RSSI); _discoveringDevices.Add(device); device.AdvertismentData = ProcessData(e.AdvertisementData); device.AdvertisedServiceUuids = ProcessUuids(e.AdvertisementData); if (_devices.All(x => x.Id != device.Id)) { _devices.Add(device); } DeviceDiscovered(this, new DeviceDiscoveredEventArgs(device)); } }