Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: First OnCharacteristicChanged not triggering subscription #1542

Open
7 of 10 tasks
Muehli-dev opened this issue Dec 14, 2024 · 2 comments
Open
7 of 10 tasks

[Bug]: First OnCharacteristicChanged not triggering subscription #1542

Muehli-dev opened this issue Dec 14, 2024 · 2 comments
Labels
bug Something isn't working more-info-needed More information needs to be provided by the issue author unverified This issue has not been verified by a maintainer

Comments

@Muehli-dev
Copy link

Component/Nuget

BluetoothLE Client (Shiny.BluetoothLE)

What operating system(s) are effected?

  • iOS (13+ supported)
  • Mac Catalyst
  • Android (8+ supported)

Version(s) of Operation Systems

Android 14
iOS 18.2

Hosting Model

  • MAUI
  • Native/Classic Xamarin
  • Manual

Steps To Reproduce

`IDisposable notificationSubscription;

var c = await x.GetCharacteristicAsync("49535343-fe7d-4ae5-8fa9-9fafd205e455", "49535343-1e4d-4bd9-ba61-23c647249616");
if (c != null)
{
Debug.WriteLine($"Characteristic found");
if (c.CanNotify())
{
Debug.WriteLine($"Characteristic can notify");
Debug.WriteLine($"Subscribing characteristic");
this.notificationSubscription = x.NotifyCharacteristic(c).SubscribeAsync(async v =>
{
Debug.WriteLine("######################################################################");
}
}
}`

Expected Behavior

Shiny.BluetoothLE.IPeripheral: Information: [Native Method - OnCharacteristicChanged
should always trigger the logic in the subscription.

Actual Behavior

Shiny.BluetoothLE.IPeripheral: Information: [Native Method - OnCharacteristicChanged
sometimes is not firing the subscription for the first OnCharacteristicChanged.

Exception or Log output

[BluetoothAdapter] getBleEnabledArray(): ON [BluetoothAdapter] BLE support array set: [true, true, true, true, true, true, true] [BluetoothAdapter] getBleEnabledArray(): ON [BluetoothAdapter] semIsBleEnabled(): ON [BluetoothAdapter] getBleEnabledArray(): ON [BluetoothLeScanner] Start Scan with callback [BluetoothLeScanner] onScannerRegistered() - status=0 scannerId=5 mScannerId=0 [ViewRootImpl@d69eb92[MainActivity]] onDisplayChanged oldDisplayState=2 newDisplayState=2 [ProfileInstaller] Installing profile for de.companyname.app [BluetoothAdapter] getBleEnabledArray(): ON [BluetoothAdapter] getBleEnabledArray(): ON [BluetoothLeScanner] Stop Scan with callback [BluetoothAdapter] BluetoothAdapter() : de.companyname.app [0:] DEVICE disconnected [DOTNET] Disconnected [BluetoothAdapter] getBleEnabledArray(): ON [CompatibilityChangeReporter] Compat change id reported: 265103382; UID 10367; state: ENABLED [BluetoothGatt] connect() - device: XX:XX:XX:XX:FC:C9, auto: false [BluetoothGatt] registerApp() [BluetoothGatt] registerApp() - UUID=3793644c-b5c6-4adf-902e-e280aa9b8217 [BluetoothGatt] onClientRegistered() - status=0 clientIf=7 [BluetoothGatt] requestConnectionPriority() - params: 0 [DOTNET] Connecting [BluetoothAdapter] getBleEnabledArray(): ON [BluetoothGatt] onClientConnectionState() - status=0 clientIf=7 device=XX:XX:XX:XX:FC:C9 Thread started: #15 [0:] Searching Characteristics [app] Accessing hidden method Landroid/bluetooth/BluetoothGatt;->refresh()Z (unsupported, reflection, allowed) [BluetoothGatt] refresh() - device: XX:XX:XX:XX:FC:C9 [0:] Shiny.BluetoothLE.IPeripheral: Information: Clear Internal Cache Refresh Result: True [BluetoothGatt] discoverServices() - device: XX:XX:XX:XX:FC:C9 [DOTNET] Connected [0:] [BluetoothGatt] onConnectionUpdated() - Device=XX:XX:XX:XX:FC:C9 interval=6 latency=0 timeout=500 status=0 [BluetoothGatt] onConnectionUpdated() - Device=XX:XX:XX:XX:FC:C9 interval=36 latency=0 timeout=500 status=0 [BluetoothGatt] onConnectionUpdated() - Device=XX:XX:XX:XX:FC:C9 interval=6 latency=0 timeout=500 status=0 [BluetoothGatt] onSearchComplete() = Device=XX:XX:XX:XX:FC:C9 Status=0 [BluetoothGatt] onConnectionUpdated() - Device=XX:XX:XX:XX:FC:C9 interval=36 latency=0 timeout=500 status=0 [0:] Characteristic found [0:] Characteristic can notify [0:] Subscribing characteristic [0:] Shiny.BluetoothLE.IPeripheral: Information: Subscribing to Notification Characteristic 49535343-fe7d-4ae5-8fa9-9fafd205e455 / 49535343-1e4d-4bd9-ba61-23c647249616 [BluetoothGatt] setCharacteristicNotification() - uuid: 49535343-1e4d-4bd9-ba61-23c647249616 enable: true [0:] Shiny.BluetoothLE.IPeripheral: Information: Subscribed to Notification Characteristic 49535343-fe7d-4ae5-8fa9-9fafd205e455 / 49535343-1e4d-4bd9-ba61-23c647249616 [0:] Shiny.BluetoothLE.IPeripheral: Information: [Native Method - OnCharacteristicChanged] Service: 49535343-fe7d-4ae5-8fa9-9fafd205e455 - Characteristic: 49535343-1e4d-4bd9-ba61-23c647249616 - Status: <======= No Log output (##########) for this OnCharacteristicChanged Thread started: #16 [0:] Shiny.BluetoothLE.IPeripheral: Information: [Native Method - OnCharacteristicChanged] Service: 49535343-fe7d-4ae5-8fa9-9fafd205e455 - Characteristic: 49535343-1e4d-4bd9-ba61-23c647249616 - Status: [0:] ###################################################################### [0:] [Received] 0146F6","FID":"E4625 [0:] Shiny.BluetoothLE.IPeripheral: Information: [Native Method - OnCharacteristicChanged] Service: 49535343-fe7d-4ae5-8fa9-9fafd205e455 - Characteristic: 49535343-1e4d-4bd9-ba61-23c647249616 - Status: [0:] ###################################################################### [0:] [Received] 0224F435726","Ser":"

Code Sample

No response

Code of Conduct

  • I have supplied a reproducible sample that is NOT FROM THE SHINY SAMPLES!
  • I am a Sponsor OR I am using the LATEST stable/beta version from nuget (v3.0 stable - ALPHAS are not taking issues - Sponsors can still send v2 issues)
  • I am Sponsor OR My GitHub account is 30+ days old
  • I understand that if I am checking these boxes and I am not actually following what they are saying, I will be removed from this repository!
@Muehli-dev Muehli-dev added bug Something isn't working unverified This issue has not been verified by a maintainer labels Dec 14, 2024
@Muehli-dev Muehli-dev changed the title [Bug]: [Bug]: First OnCharacteristicChanged not triggering subscription Dec 14, 2024
@aritchie
Copy link
Member

I have not seen this issue before. Are you sending a notification immediately upon subscription? How do I repro this?

Have you tried WhenNotificationReceived & EnableNotification directly?

@aritchie aritchie added the more-info-needed More information needs to be provided by the issue author label Dec 16, 2024
@Muehli-dev
Copy link
Author

Yes, the device i'm connecting with is sending data immediately upon subscription.
I've not yet tried WhenNotificationReceived & EnableNotification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working more-info-needed More information needs to be provided by the issue author unverified This issue has not been verified by a maintainer
Projects
None yet
Development

No branches or pull requests

2 participants