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

Multiple BLE connections alternating so buffer doesnt get overflood #45

Open DaanP-2056102 opened 1 year ago

DaanP-2056102 commented 1 year ago

Hello I managed to connect 3 BLE devices and everything works super fine, thanks for the DLL.

But for my application (thesis). I have to read data simultaneously meaning that I am reading 0.5 seconds the data from Sensor1, then 1 second reading my sensor 2, and then sensor 3. The buffer data always gets messed up and my code is reading the wrong sensor for each data field. Is it possible to switch between connected BLE devices and then make a scheduler to indicate when every sensor is allowed to read or is this simply not possible with your DLL? Thanks in advance

adabru commented 1 year ago

Do you check the deviceId in each data package?

The dll buffer should be unlimited (i.e. RAM size) and both the writing and the reading are synchronized.

https://github.com/adabru/BleWinrtDll/blob/f2635b7b02432ea3006983657107f092c862171d/BleWinrtDll/BleWinrtDll.cpp#L203

Do you mean the OS/hardware buffer? How large are your bluetooth packages?

I'd guess switching on/off is only supported with unsubscribe/subscribe. But you can try to find the functionality in the Microsoft's UWP BLE documentation (C#). If you find it you can port it to this dll.

DaanP-2056102 commented 1 year ago

Hey there thanks for the insights. I thought that when I called "polldata" I was asking the BLE sensor to send data. But it just always sends data and it is up to me to detect the deviceId and then call the correct method. Thanks a lot for the fast reply!

adabru commented 1 year ago

Yeah that's probably confusing because "ReadCharacteristic" is not implemented in the dll although it is a ble functionality. If you need it you can checkout https://github.com/adabru/BleWinrtDll/issues/6#issuecomment-1480375448 .