Skip to content

Commit

Permalink
Initial fix for #1381
Browse files Browse the repository at this point in the history
  • Loading branch information
aritchie committed Mar 6, 2024
1 parent c748ac0 commit 2226cb5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public IObservable<BleCharacteristicResult> NotifyCharacteristic(string serviceU
.Switch()
.Select(ch => this.operations.QueueToObservable(async ct =>
{
characteristic = ch;

this.FromNative(ch).AssertNotify();
this.logger.LogDebug("Char InstanceID: " + ch.InstanceId);

Expand All @@ -95,13 +97,13 @@ public IObservable<BleCharacteristicResult> NotifyCharacteristic(string serviceU
if (nativeDescriptor == null)
throw new BleException("Characteristic notification descriptor not found");

ct.ThrowIfCancellationRequested();
await this.WriteDescriptor(nativeDescriptor, notifyBytes, ct).ConfigureAwait(false);
this.logger.HookedCharacteristic(serviceUuid, characteristicUuid, "Subscribed");

this.AddNotify(ch);
this.charSubSubj.OnNext(this.FromNative(ch));

characteristic = ch;
return ch;
}))
.Switch()
Expand Down Expand Up @@ -167,7 +169,7 @@ public IObservable<BleCharacteristicInfo> WhenCharacteristicSubscriptionChanged(
protected void TryNotificationCleanup(BluetoothGattCharacteristic ch, string serviceUuid, string characteristicUuid)
{
try
{
{
this.RemoveNotify(ch);

if (this.Status == ConnectionState.Connected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public IObservable<BleCharacteristicResult> NotifyCharacteristic(string serviceU
.Switch()
.Select(ch =>
{
native = ch;
this.FromNative(ch).AssertNotify();

native = ch;
this.logger.CharacteristicInfo("Hooking Notification Characteristic", serviceUuid, characteristicUuid);
this.Native.SetNotifyValue(true, ch);

Expand Down

0 comments on commit 2226cb5

Please sign in to comment.