Comments (11)
I agree! 👍 I'll see what I can manage, I'll let you know when I get a chance to look at it.
from bleno-mac.
Interesting! I won't have a chance to look at it this week I don't think, and nothing comes immediately to mind.
I'll try setting up a purely native harness and see if it's a macOS issue, or an issue with the dispatching across to JS.
How much data are you writing? Do you have a small repro you can provide?
from bleno-mac.
I'll try to provide an example, though basically I call updateValueCallback
twice in a row.
From my understanding, there is some backpressure management in the Apple framework. So, there should probably be some queueing in place in order to avoid this.
As a reference : https://developer.apple.com/documentation/corebluetooth/cbperipheralmanagerdelegate/1393248-peripheralmanagerisreadytoupdate
from bleno-mac.
Ahh right, of course, that would make sense! That should be (hopefully) be simple enough. I remember thinking about that, and if(& how) that would be exposed back to the JS side without complicating the non-Apple implementations. I think a "fire and forget" from the JS side is probably fine since it's all async anyway, but I'm not sure if there are cases where you'd want to know when a value is queued (and eventually fired). Thoughts?
from bleno-mac.
My views are the following: keep it simple (fire and forget) and hide it in the Apple implementation, seems to make quite a lot of sense.
Source: I do it this way on Android ;)
The alternative would be to return a Promise, letting us know when and if the write completes
from bleno-mac.
Awesome, if I get some time I'll try to dig in the native code and documentation too.
from bleno-mac.
Hey @saiimons and @notjosh did you guys ever figure out how to get this to work? I'm hitting it now too.
from bleno-mac.
Well I experimented and found this works, not sure I'm happy about it but if it helps...
I tried promises but not very hard, it seems like it's a timing issue because timeout doesn't work.
function chunkData(str, size) {
const chunks = new Array(Math.round(str.length / size));
let newo = 0;
for (let i = 0, o = 0; i < chunks.length; i += 1, o = newo) {
newo += size;
chunks[i] = str.substr(o, size);
}
return chunks;
}
function wait(ms) {
const waitTill = new Date(new Date().getTime() + ms);
while (waitTill > new Date()) { /* Don nothing */ }
}
const chunks = chunkData('Bob is your uncle and stuff like that', maxMessageResponseValueSize);
chunks.forEach((chunk) => {
const data = Buffer.from(chunk, 'utf-8');
console.log(chunk);
messageUpdateValueCallback(data);
wait(10);
});
from bleno-mac.
Do either of you happen to have a simple repro project? I'm sure it's easy enough, but I don't know how many "multiple" is, or how quickly we're talking.
I think I know the issue, but not certain.
from bleno-mac.
@notjosh here is a gist, it's a dumbed down version of what I am working on and has not actually been run as is but should work https://gist.github.com/cwhittl/2bc19de82df28f2b415b8cd77180d2f4
from bleno-mac.
If you remove the wait you only see the first callback on my android app, if you leave the wait it does all of them
from bleno-mac.
Related Issues (13)
- Cannot connect with CBErrorDomain Code=6
- Question: Documentation for adapters
- Segmentation Fault 11 Error HOT 9
- stateChange is not working on catalina HOT 1
- Incompatible architecture issue on mac m1
- macOS 10.14.2 no services or characteristics being broadcast on Android HOT 5
- install fails to compile HOT 1
- Advertising service UUID not actually being advertised HOT 4
- Unable to Set ArrayBuffer Value for Descriptor HOT 1
- Possible to make the maxValueSize larger?
- does this module support startAdvertising? HOT 1
- Status / Demo HOT 1
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 bleno-mac.