Web bluetooth multiple devices

Posted on
  • I see a bit of weirdness when connecting multiple devices via web bluetooth.

    Connect first device, read RX to console. Connect second read RX to console, first devices stops being read - nothing in from it in console. Connect first device again. Both devices now show their RX in console.

    I can repeat this. Anyone else?

    Edit:

    Can also ask about how people are differentiating the device responsible for the UART RX in their web bluetooth applications. I'm setting up two objects, but seeing RX from two devices associated with last connected device.

    I'd like to be able to identify which device is sending what.

  • Solved both issues by starting again from this page which is very helpful boilerplate.

    https://beaufortfrancois.github.io/sandb­ox/web-bluetooth/generator/

  • Hey @Ollie, I'm glad this page helped.
    Do you mind sharing what you were doing so that others can benefit.
    We could update https://developers.google.com/web/update­s/2015/07/interact-with-ble-devices-on-t­he-web and add a warning if it is a common issue.

    Thanks in advance ;)

  • It might be some problem with the puck.js helper library - but if so it'd be really handy to get it sorted so it doesn't hit anyone else :)

  • Hi @Gordon. No it wasn't the puck.js library -I've had no problems with that, but I haven't tried to run multiple connected devices TBH or two way comms.

    I was using the Web bluetooth API directly since I know nothing about it, and wanted to familiarise myself.

    @François - i've just twigged that is your page - thanks! I'm afraid I don't have much of my code left to share, I was experimenting on a saturday afternoon so nothing under version control. The fact the boilerplate worked suggests it was me - promises are a bit new to me TBH. Should I be able to replicate it I will post code.

  • What is the limit to the number of connections over web bluetooth - is it hardware dependent?

    And could the connection dialog that pops up allow selection of multiple devices. Say I am connecting 3 pucks, it would be good to select them all and leave the browser to iterrate through the connections, rather than have to go back to the dialog three times.

    Just a thought after using the interface for a while now :)

  • What is the limit to the number of connections over web bluetooth

    Yes, it depends on hardware. @François will know better than me but I think it's around 6 - not lots anyway.

    Multiple selection would be good, but I imagine it's a way down their priority list. Personally I'd like to see a 'remember this choice' checkbox - I think that could be really powerful, and might ease your multi-selection pain as well!

  • Thanks - I have had 5 pucks connected. That's all I have so can't test 6 or 7.

    Anyway, this is what I have so far if interested - basically a gateway using Web Bluetooth. I started from @François's boiler plate.

    https://olliephillips.github.io/webbleMQ­/

    I plan to attempt to add the HTTP proxy and MQTT gateway but I think that's likely to need a server backend to be reliable. But I am out of time for now - unfortunately work beckons - but I will come back to this. Lots of potential!

    Edit: README with some info on what it does https://github.com/olliephillips/webbleM­Q

  • Here's what we know from Emil:

    Unfortunately, no platforms I'm aware of have well-defined behaviour
    nor documented APIs to handle the case when the maximum number of
    connections is reached. It seems people working on Bluetooth stacks
    have not really thought, cared about or even tested what will or
    should happen if users have many BLE devices. As an example, the
    Bluetooth stack in Android hangs if you have 7 BLE connections and try
    to establish the 8th with "autoConnect=true" (in the way that it will
    never again connect to BLE devices until Bluetooth is restarted, even
    if the 7 get disconnected). If you have GATT notifications you listen
    to in Windows and are above the maximum number of connections, you get
    no event telling this, so some notifications will not be delivered to
    your computer (since the peripheral can't connect). Generally among
    most platforms some random error code is thrown (general failure,
    internal error, unspecified error, gatt error) when you actively try
    to connect a new device when the maximum number of connections has
    been reached. Sometimes a better error code like "no resources" is
    thrown. The non-existing documentation of error codes that is
    unfortunately general among all BLE implementations is very annoying
    when you are an app developer (Windows must be the worst when they're
    trying to map BLE errors to their general 0x80... HRESULT error
    codes).

    Source: https://github.com/WebBluetoothCG/web-bl­uetooth/issues/342#issuecomment-26811708­5

  • Thanks for this. So Android Bluetooth capped at 7 connections, by design or otherwise.

    I'm also interested in other hardware/stack constraints too. While it would be relatively simple to detect device and act on limits in a web app - we'd need to know what they are.

    How can I find/monitor this?

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Web bluetooth multiple devices

Posted by Avatar for Ollie @Ollie

Actions