public override void OnCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) { base.OnCharacteristicChanged(gatt, characteristic); BLECharacteristic bleCharacteristic = null; foreach (BLEService bles in services) { foreach (BLECharacteristic blec in bles.Characteristics) { if (blec.UUID.StringValue == bleCharacteristic.UUID.ToString()) { bleCharacteristic = blec; break; } } } EventHandler <BLECharacteristicEventArgs> handler = UpdatedCharacteristicValue; if (handler != null) { BLECharacteristicEventArgs args = new BLECharacteristicEventArgs(); args.Characteristic = bleCharacteristic; handler(this, args); } }
void OnUpdatedCharacteristicValue(object sender, CBCharacteristicEventArgs e) { BLECharacteristic characteristic = null; foreach (BLEService bles in services) { foreach (BLECharacteristic blec in bles.Characteristics) { if (blec.UUID.StringValue.Equals(e.Characteristic.UUID.ToString())) { characteristic = blec; break; } } } characteristic.Value = e.Characteristic.Value.ToArray(); EventHandler <BLECharacteristicEventArgs> handler = UpdatedCharacteristicValue; if (handler != null) { BLECharacteristicEventArgs args = new BLECharacteristicEventArgs(); args.Characteristic = characteristic; args.Error = e.Error?.ToString(); handler(this, args); } }