Comments (5)
Using the BLE characteristic "Notify" seems right to me.
I'm not sure what may be the cause in your description. One thing you could try out is changing your bluetooth dongle. For my project I tried 3 different ones until the last one had the performance I'd expect from BLE. But I doubt that is the reason here.
The timespan of half a minute reminds me of another thing. I am also using an ESP32. The BLE-connection (scan + Connect()
) normally takes less than a second. Also the subscription to the characteristic notify event is normally very fast. The data is sent with latencies around <10-50ms, I didn't measure more exactly yet. After subscription the ESP32 starts sending its packages. Now, if I restart the program and it tries to reconnect, I have to wait somewhere between 30-60s before it connects again. I found out that the ESP is sending out packages around 60s after subscrption. Then it will stop sending them if it didn't receive any response from Windows. I guess it will think the connection was lost. If I send any BLE package from Windows to the ESP the 60s-timer is reset. I am not sure why Windows can't connect to the ESP while it is sending its package-stream. My guess was data-congestion on ESP-side. In my case I added code to the ESP that reduces the timer to 1s, so that reconnection is faster.
Another problem I had was when I sent data from the ESP too fast. I guess that was also due to data congestion, probably on ESP side but could also be on dongle or Windows side. Enforcing a maximum packages per second rate should avoid that. That could explain why it starts working when your ESP waits 512 sensor readings before it sends a package.
from blewinrtdll.
Or you can try out writing packages to your ESP in a regular interval (<30s, e.g. 2s).
from blewinrtdll.
Thanks again for the help. You definitely brought be on the right track here again :)
I looked a bit closer inside your BleWinrtDll.cpp and it seems that you are actually using the Notification for characteristics subscription:
fire_and_forget SubscribeCharacteristicAsync(wchar_t* deviceId, wchar_t* serviceId, wchar_t* characteristicId, bool* result) {
....
....
auto status = co_await characteristic.WriteClientCharacteristicConfigurationDescriptorAsync(GattClientCharacteristicConfigurationDescriptorValue::Notify);
So accessing
Impl.PollData(out packageReceived, true);
packageReceived.buf[0]
should be sufficient for reading a byte from the characteristic. I was a bit on the wrong track in thinking that the problem was on my processing on the Unity side.
Turns out, the keyword for my problem is, like you mentioned, "data congestion". After reading your reply I tried one simple thing.
On my ESP32 program, after sending my packet, I added a simple delay(50):
pCharacteristicCommand->setValue(package, 1);
pCharacteristicCommand->notify();
delay(50);
.. and this ACTUALLY seems to have done the trick. It's not that I hadn't thought about it, but idk like I said - I was a bit on the wrong track :)
I will have to fiddle around with and tweak it a bit, but overall I think that may have solved my problem!
from blewinrtdll.
@adabru Do you remember the dongle that you used?
from blewinrtdll.
@adabru Do you remember the dongle that you used?
Sorry, I don't
from blewinrtdll.
Related Issues (20)
- BleWinrtDll.cpp:389 Error scanning characteristics from service {0000180d-0000-1000-8000-00805f9b34fb} width status 3 HOT 1
- Multiple devices support HOT 6
- Enable Indication into Client Characteristic Configuration HOT 1
- Device not connecting after scanning HOT 4
- Got error w很 HOT 6
- Connecting to more than one Ble Device HOT 2
- How can i subscribe to multiple BLE characteristics? HOT 2
- How can i get more than 30 packets a second. HOT 2
- After called Quit(),Can not find any connectedable devices. HOT 2
- How to make it work on Android? HOT 3
- Connection with multiple devices HOT 2
- Missing DLL after Build HOT 2
- Not working with baudrate 115200
- Using dll in the Unity but can't subscribe HOT 1
- Multiple BLE connections alternating so buffer doesnt get overflood HOT 3
- Why can't BleWinrtDll.dll be called when this project is deployed to HoloLens? HOT 2
- Connecting and Subscribing to heart sensor HOT 3
- Unable to write attribute HOT 5
- Suddenly unable to subscribe to notifications from and write to characteristic HOT 1
- Communication with Dongle
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blewinrtdll.