private void OnCharacteristicFound(object sender, FindInformationFoundEventArgs e) { if (_deviceService == null) { return; } var characteristic = BleMappings.MapBleDeviceCharacteristic(e); if (characteristic == null) { return; } if (characteristic.CharacteristicId != Guid.Empty) { _lastCharacteristic = characteristic; if (!_deviceService.Characteristics.ContainsKey(characteristic.CharacteristicId)) { _deviceService.Characteristics.Add(characteristic.CharacteristicId, characteristic); } } else if (_lastCharacteristic?.Handle > 0 && _lastCharacteristic?.ClientCharacteristicConfiguratorDescriptorHandle == 0) { _lastCharacteristic.ClientCharacteristicConfiguratorDescriptorHandle = characteristic.Handle; } }
private void OnClientAttributeValueEvent(object sender, AttributeValueEventArgs e) { var attribute = BleMappings.MapBleDeviceAttribute(e); if (attribute == null) { return; } _attributeNotifications?.Invoke(attribute); }
private void OnServiceFound(object sender, GroupFoundEventArgs e) { if (_device == null || e.end == 0 || e.uuid.Length < 15) { return; } var service = BleMappings.MapBleDeviceService(e); if (service == null) { return; } if (!_device.Services.ContainsKey(service.ServiceId)) { _device.Services.Add(service.ServiceId, service); } }
private void OnDeviceConnected(object sender, StatusEventArgs e) { var deviceStatus = BleMappings.MapBleDeviceStatus(e); if (_device == null || deviceStatus == null || _device.Address != deviceStatus.Address) { return; } if (deviceStatus.IsConnected) // Connected { // Service Discovery _bglib.SendCommand(_serialPort, _bglib.BLECommandATTClientReadByGroupType(e.connection, 0x0001, 0xFFFF, new byte[] { 0x00, 0x28 })); // "service" UUID is 0x2800 (little-endian for UUID uint8array) } else { _logger.LogInformation( $"ControlPlus Repository: Connection changed: {deviceStatus.Address} {deviceStatus.Flags}"); } }
private void OnDeviceFound(object sender, ScanResponseEventArgs e) { _deviceNotifications?.Invoke(BleMappings.MapBleDevice(e)); }