Giter Club home page Giter Club logo

Comments (11)

notjosh avatar notjosh commented on September 9, 2024 1

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.

notjosh avatar notjosh commented on September 9, 2024

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.

saiimons avatar saiimons commented on September 9, 2024

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.

notjosh avatar notjosh commented on September 9, 2024

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.

saiimons avatar saiimons commented on September 9, 2024

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.

saiimons avatar saiimons commented on September 9, 2024

Awesome, if I get some time I'll try to dig in the native code and documentation too.

from bleno-mac.

cwhittl avatar cwhittl commented on September 9, 2024

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.

cwhittl avatar cwhittl commented on September 9, 2024

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.

notjosh avatar notjosh commented on September 9, 2024

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.

cwhittl avatar cwhittl commented on September 9, 2024

@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.

cwhittl avatar cwhittl commented on September 9, 2024

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)

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.