-
• #2
Try adding a delay between disconnecting from one puck and connecting to the other. Disconnect starts a disconnect but it takes some time to complete, and the web Bluetooth spec doesn't seem to remove a return a promise.
Unfortunately notifications aren't implemented yet, so you can't get the result. It'll be in a firmware update in the new year though
-
• #3
Thanks again, Gordon.
Adding the timeout solved it:
scan( function( queue ) { // recurse through queue function process() { if( queue.length ) { transfer( queue.pop(), command, function( result ) { console.log( "done" ); setTimeout( process, 150 ); }); } } process(); });
150 ms seems sufficient.
I was able to go down to about 145 ms, but everything below still caused some errors.I'm very thrilled to get the notifications.
Good work - keep it up!
Having 5 pucks at hand I'd like to do some round-robin communication:
I am aware, that connection multiple peripherals at the same time is not possible atm, so I do it sequentially (with recursive callbacks).
This is my connection code:
Issue A:
As long as I disable (/**/) the receiving part I can pass commands to the first puck successfully.
But when I try to connect the second one I get BLE error 18 - why?
Question: What does that mean and what can I do about it?
Issue B:
I also like to get the feedback of the command sent to the pucks.
So I tried to add the receiver part (in comments) but it always receives the echo of the data I just sent.
Question: How can I get the full response and how do I detect the end of a transmission?
I'll upload the full sourcecode as attachment so you have the complete picture.
Thanks in advance,
Christian
1 Attachment