adabru / BleWinrtDll

BLE for Unity 3d in Windows without UWP.
Do What The F*ck You Want To Public License
168 stars 52 forks source link

Unable to scan for or subscribe to characteristics #21

Open nicg220 opened 2 years ago

nicg220 commented 2 years ago

Hello.

I am able to search and find my BLE device, as well as successfully searching for a list of services. When I select 'scan characteristics' however, I am either met with no results, or the error "BleWinrtDll.cpp:429 ScanCharacteristicsAsync catch: Catastrophic failure". As such, I am unable to subscribe to and read incoming data from the device.

I'm just wondering if anyone has faced this issue?

Thank you!

Ugobyte commented 2 years ago

I faced a similar issue. I'm able to Find Devices, Find Services and Find Characteristics. But I cannot Subscribe to Characteristics.

I noticed I can only Subscribe to known Characteristics such as Battery, Serial Number, Model Number, Heart Rate, etc... (These are the Characteristics listed in BLE Documentation)

However, I created my own custom Characteristic in my Little BLE Pet project. I can see my custom-made characteristics but I cannot subscribe to them. I get BleWinrtDll.cpp:501 SubscribeCharacteristicAsync catch: The Attribute cannot be written to.

Ugobyte commented 2 years ago

[SOLVED]

I got it to work. It has always worked. When i do a BLEApi.SubscribeToCharateristic() It is successfully subscribing to my custom characteristics under the hood. The UI is just displaying error that isn't actually an error. Also, when i do a BLEApi.PollCharacteristics(), the bytes from my custom characteristics are coming in as well.

I'm guessing the BleWinrtDll.cpp:501 SubscribeCharacteristicAsync catch: The Attribute cannot be written to. error message probably means it does not know how to parse and display my custom characteristics.

ehauner commented 2 years ago

This might be related to an issue I found where the characteristics dropdown in the Demo scene was not correctly hooked up to the SelectCharacteristic function in the Demo script, so it was always subscribing to the first characteristic regardless of your selection. See my post in #20 for more info.