Coder Social home page Coder Social logo

Unable to write to device about blewinrtdll HOT 7 OPEN

adabru avatar adabru commented on July 22, 2024
Unable to write to device

from blewinrtdll.

Comments (7)

adabru avatar adabru commented on July 22, 2024 2

For investigation, you can download and run the Microsoft's Bluetooth Low Energy sample and see whether writing the characteristic works there.

Can you see any error message in the GUI?

You could also try out changing GattWriteOption::WriteWithoutResponse to GattWriteOption::WriteWithResponse at https://github.com/adabru/BleWinrtDll/blob/main/BleWinrtDll/BleWinrtDll.cpp#L536 . That would make the call wait for the BLE device to send a "I received" confirmation. In BLE terms that would be "request"+"response" instead of a "command" without a response.

from blewinrtdll.

ashfrog avatar ashfrog commented on July 22, 2024 1

co_await characteristic.WriteValueWithResultAsync(buffer, GattWriteOption::WriteWithResponse);
this works fine

from blewinrtdll.

ehauner avatar ehauner commented on July 22, 2024 1

if I have only one characteristic the write button works fine

Thank you. This hint helped me solve this issue. I logged a bunch of things and found out that changing the characteristics dropdown was not correctly setting the selected characteristic in the script. It was always trying to subscribe to the first one since the script selects the first item by default.

This issue is that the dropdown was never hooked up to the SelectCharacteristic function in the Demo script.

Simple fix:

  1. select the characteristics dropdown in unity
  2. in the inspector, find "On Value Changed (Int32)" in the "Dropdown" component
  3. add Demo.SelectCharacteristic and pass "DropdownCharacteristic" as the argument

from blewinrtdll.

MikEfraim avatar MikEfraim commented on July 22, 2024

Hello,

I managed to compile the code and changed the line 536. I then customized the Unity code and I'm trying to write a letter "C" or "F" but when I press the Write Button I get:

"BleWinrtDll.cpp:545 SendDataAsync catch: The attribute cannot be written."

I also seem to subscribe to the first characteristic of my BLE peripheral despite clicking on the second characteristic.

This bug only happens from within unity, it doesn't happen with either the BLE scanner app from my android phone nor the same PC BLE scanner app. Those apps seem to work fine.

Edit: It seems if I have only one characteristic the write button works fine. I'll make a few more tests and try to figure out the culprit.

from blewinrtdll.

adabru avatar adabru commented on July 22, 2024

@ehauner would you mind creating a pull request :) ? Currently I don't have the setup to test this.

from blewinrtdll.

tommasoFabbri avatar tommasoFabbri commented on July 22, 2024

Hi,
we started to use the BlewinrtDll we need it for our Unity app and the solution seems great.

we can connect to the BLE device and can receive data but the function "SendData" always return false

we have try to use the precompiled dll that e find in the unity example non threaded
the device can recieve correctly from/with other libraries for ios and Mac

we have tried also this

You could also try out changing GattWriteOption::WriteWithoutResponse to GattWriteOption::WriteWithResponse at https://github.com/adabru/BleWinrtDll/blob/main/BleWinrtDll/BleWinrtDll.cpp#L536 . That would make the call wait for the BLE device to send a "I received" confirmation. In BLE terms that would be "request"+"response" instead of a "command" without a response.

but the returnis still false.

what can we do about it?

Thank you in advance.

from blewinrtdll.

adabru avatar adabru commented on July 22, 2024

Hi @tommasoFabbri :),
please open a new issue and write which error message you are getting. Please also try the Microsoft provided sample linked in the Readme to checkout if sending data works there.

from blewinrtdll.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.