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

Write to FTMS Device #26

Open
serramat opened this issue Feb 23, 2022 · 6 comments
Open

Write to FTMS Device #26

serramat opened this issue Feb 23, 2022 · 6 comments

Comments

@serramat
Copy link

serramat commented Feb 23, 2022

Hi,
I am using your library to read the data from the BLE sensors and I was able to receive the information correctly.
Now I would also need to write data on some devices (such as assigning the friction to a roller). I am using the WritePackage but I can never write! I also tried your example but without any success.

To be precise I'm trying to write on the 00002ad9-0000-1000-8000-00805f9b34fb characteristics of the 00001826-0000-1000-8000-00805f9b34fb service

Thank you so much.
Matteo.

@adabru
Copy link
Owner

adabru commented Mar 20, 2022

Hi @serramat , you could try the things mentioned in #20 (comment) .

@ShuohengZhang
Copy link

Hi @serramat , you could try the things mentioned in #20 (comment) .

Hi adabru, thanks for your great work on this BLE.dll! By the way I have the similar problem as @serramat had. The whole DLL worked very well since I use it, and since October the write value is down. There's no errors but only the FTMS indoorbike doesn't react to the value it received. Specifically I want to change 2 Bytes ('0x11, 0x00, 0x00, Byte1, Byte2, 0x00, 0x00'). I tried changing GattWriteOption::WriteWithoutResponse to GattWriteOption::WriteWithResponse at https://github.com/adabru/BleWinrtDll/blob/main/BleWinrtDll/BleWinrtDll.cpp#L536 . , this doesn't work in my case, but I tried with nRF Connect on iOS system. Where I write '110000DC050000' would make the FTMS indoorbike change its inclination grade to '15' correctly. I even wrote a UWP application to test the function, and surprisingly it works. But as I use the UWP specific API, I cannot make it into a dll and import to Unity. And I'm stucking to this problem for a month but I still cannot figure out where's the problem. Could u please help me out ?

@adabru
Copy link
Owner

adabru commented Jan 12, 2024

Hi @ShuohengZhang ,
it's good that your UWP application works. The dll in this repository is a c++ winrt wrapper for UWP code so the step from your UWP app to the dll should be small.

You can compare the UWP function calls from https://github.com/adabru/BleWinrtDll/blob/main/BleWinrtDll/BleWinrtDll.cpp with your UWP app. If your UWP app uses another API-call, you can change that in BleWinrtDll.cpp. Or you can change the API-call in your UWP app to the same as in BleWinrtDll.cpp.

As reference for converting UWP code to c++ winrt and vice versa, you can use
https://github.com/microsoft/Windows-universal-samples/blob/main/Samples/BluetoothLE/cppwinrt/Scenario2_Client.cpp
and
https://github.com/microsoft/Windows-universal-samples/blob/main/Samples/BluetoothLE/cs/Scenario2_Client.xaml.cs
Those are functionally the same.

@ShuohengZhang
Copy link

Hi @adabru,
Thanks for your reply!! And yeah, I was a bit afraid to write a C++ DLL by myself because I don't really understand the C++ codes that well. However, I tried it with your suggestions today and looked into your codes and the samples I made (Dll_BLE.cpp). When I import this DLL into the Unity project, there is a DllNotFoundException when I already put it in the same folder as your BLEWinrtDll (I assume when this DLL can be used, so should mine). I would so appreciate hearing your suggestions!!

Best regards!

@adabru
Copy link
Owner

adabru commented Jan 13, 2024

I'm not quite sure what the reason for the DllNotFoundException is. You can try to look at Unity's import settings for that file. You can also try to change the 32-bit or 64-bit setting in VS. And maybe try to ask ChatGPT.

Is your repository private? I can't access the link.

@ShuohengZhang
Copy link

@adabru sorry I didn’t notice that was private now u may have the access. And thanks again that you still concern about my case !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants