public static void AssertWrite(this IGattCharacteristic characteristic, bool withResponse) { if (!characteristic.CanWrite()) { throw new ArgumentException($"This characteristic '{characteristic.Uuid}' does not support writes"); } if (withResponse && !characteristic.CanWriteWithResponse()) { throw new ArgumentException($"This characteristic '{characteristic.Uuid}' does not support writes with response"); } }