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 devices support #32

Closed tufeixp closed 2 years ago

tufeixp commented 2 years ago

Does this lib support a multiple devices running?

adabru commented 2 years ago

I think yes but I didn't try. See https://github.com/adabru/BleWinrtDll/issues/7#issuecomment-771600983:

I guess each bluetooth device normally has a unique device id. In that case you should be able to just call the functions with different device-ids. Each received data-package contains information about the device it was sent from. Likewise, in each data-package you send you can specify the device-id it should go to.

tufeixp commented 2 years ago

Yes, I tried and it works~ thanks~

mnajib76 commented 2 years ago

Hi @tufeixp , can you share your code/project how you read the data when connect to more than 1 device?

mnajib76 commented 2 years ago

image

So based on my understanding we need to SubscribeCharacteristic() for both devices id , services and char id, and all buffer will still pull from the function as in picture above?

adabru commented 1 year ago

Hi @mnajib76, you are right. You pull from the function and determine which device it was sent from by inspecting res.deviceId. https://github.com/adabru/BleWinrtDll/blob/31fcc9fd733e16a80d712ece893caf0c678f9111/BleWinrtDll/BleWinrtDll.h#L22-L28

mnajib76 commented 1 year ago

Thank you very much! Manage to do it!