22 votes

Building cross-platform offline-first apps with Bluetooth Low Energy

9 comments

  1. [6]
    talklittle
    Link
    In the early '10s there was a framework called AllJoyn made by Qualcomm, meant to bridge the competing protocols, Bluetooth among them. I played around with it and wanted to try some...

    In the early '10s there was a framework called AllJoyn made by Qualcomm, meant to bridge the competing protocols, Bluetooth among them. I played around with it and wanted to try some device-to-device app ideas.

    Unfortunately the AllJoyn project hit a major wall, IIRC in large part due to Android's gutting of their Bluetooth stack and replacing with a completely different one. I found a mention of that on the Bluetooth stack Wikipedia article:

    Android switched from BlueZ to its own BlueDroid stack, created by Broadcom, in late 2012. BlueDroid has been since been renamed Fluoride. Marcel Holtmann from the Intel Open Source Technology Center, claimed that Google made a poor choice in switching to BlueDroid, during a presentation for BlueZ for Android at the Android Builders Summit in 2014.

    This presentation posted by OP about modern Bluetooth is welcome info. For one, sounds like no more competing protocols worth considering; just use Bluetooth. Another, iOS 11 and Android 10 finally expose the APIs needed (L2CAP) to build apps with less friction. Even though the Internet of Things fad is over, I hope we'll see developers experiment more with local device-to-device apps.

    3 votes
    1. [5]
      papasquat
      Link Parent
      It makes me sad to think how much more powerful smartphones could be if we just were able to break them free of the profit motive of carriers. One of my favorite TV shows (and book series) is The...

      It makes me sad to think how much more powerful smartphones could be if we just were able to break them free of the profit motive of carriers.

      One of my favorite TV shows (and book series) is The Expanse. It's a Sci Fi show about a humanity that has colonized most of the solar system. In it, everyone uses a device that is somewhat analogous to a cell phone, called a hand terminal.

      It works more like a highly advanced military radio than a cell phone though, because of it's sheer flexibility. Because it's designed to be used by people that work out in the depths of space, it can be used in a lot of different modes. One mode is similar to a 5g cell phone; it connects to a stationary network on a space station or planet, which routes packets to wherever they need to go. Another mode is on a spaceship, where it automatically connects to a similar network there, and if it's authorized, can be used to interface with the ships computer.

      The third mode is something I wish for all the time. The terminals, in a sense of a cell signal, make a mesh network amongst themselves, and can be used in the same way as a point to point radio.

      So many times I wish my cell phone could do this.
      I have a very sophisticated, poweful OFDM tranciever radio in my pocket. Why doesn't it automatically talk to other radios in the area? Probably because then I wouldn't need to pay Verizon or T-Mobile or ATT in many situations.

      I know there are apps that can use wifi or Bluetooth to send messages with other people they have the app, but this seems like no brainer, basic functionality that should be built into cell phones.

      If I'm out camping with my friends, why can't I just text or call them if they're a half mile away?

      3 votes
      1. [4]
        Weldawadyathink
        Link Parent
        I am far from a wireless signaling expert, but I don’t think that could work in practice with current phones without trade offs that customers wouldn’t want. The radios in phones are designed to...

        I am far from a wireless signaling expert, but I don’t think that could work in practice with current phones without trade offs that customers wouldn’t want. The radios in phones are designed to broadcast at incredibly low power. Cellular radios operated by the carrier are designed to be able to pick up these low power signals and amplify them. Radios in phones very likely couldn’t amplify and understand signals sent from other handsets. You would have to make the phone radios much more powerful, which means more battery usage, physical size, heat generation, etc. And all this for a feature that very few customers would actually use. And the few that could use it probably already have a set of point to point radios that would work better anyway.

        Again, I could be wrong about this, but I don’t think it’s as simple as building out the software. I think the hardware would need significant changes too.

        1 vote
        1. [3]
          papasquat
          Link Parent
          Well, in duplex communication, both sides are transceivers, which means they need to be able to both transmit and receive signals above the base SNR needed to extract meaningful data. The tower...

          Well, in duplex communication, both sides are transceivers, which means they need to be able to both transmit and receive signals above the base SNR needed to extract meaningful data. The tower doesn't have any specialized magic equipment that can reduce the noise floor, it needs to be able to pluck a cell phones radio waves out of the noise, just as the cell phone needs to pluck the towers signal out of the noise. That means that the handset needs to broadcast with enough power to cut through the noise, just as the tower does, so inherently, they need to transmit at roughly the same power level (obviously the tower is talking to a ton of handsets using multiplexing, so is transmitting a lot more and thus using more power, but not for that single connection).

          For a broadcast radio tower doing simplex communication, you can just put an extremely powerful transmitter very very high up and blast megawatts of radio waves out there, and people can hear you from all over, but for cell towers, you need to be able to hear tony handsets, so that doesn't work, so they're way smaller, and way lower power, to talk at roughly the same power levels as the phones they're talking to.

          I think you'd almost certainly need to make protocol changes, and maybe even different hardware, because much of that protocol info is likely hardcoded into cell radios. I don't think you'd fundamentally have to change how cellphones are designed or make any compromises in their design to achieve seamless point to point communications though. (Spectrum management would be a potential issue in crowded areas though, and would have to be carefully managed).

          1 vote
          1. [2]
            Weldawadyathink
            Link Parent
            I didn’t communicate very clearly, but this is where (I am pretty sure) your assumptions fail. Both antennas and amplification circuits can do some pretty incredible things with the noise floor....

            The tower doesn't have any specialized magic equipment that can reduce the noise floor

            I didn’t communicate very clearly, but this is where (I am pretty sure) your assumptions fail. Both antennas and amplification circuits can do some pretty incredible things with the noise floor. The antennas in particular often have to be quite large to do this. Take a look at what ham radio operators use: large antenna. Yes, there are a lot of things we can do to make good antenna smaller, but that means more cost and complexity.

            Another example is phased array or similar interference based antenna. Cell towers use this type of antenna, but it isn’t really feasible with our current technology to put a phased array antenna in a cell phone.

            You say these communications are full duplex, but the two directions of the signal are not equal in their electromagnetic properties. If you need proof of this, run a speed test on cellular. Basically anywhere in the world you will have much faster download speed than upload speed.

            1. papasquat
              Link Parent
              The size of an antenna element isn't dictated by the power or amount of noise filtering, it's dictated by the wavelength of the carrier wave. HAM operates on bands between one and a couple...

              The antennas in particular often have to be quite large to do this. Take a look at what ham radio operators use: large antenna.

              The size of an antenna element isn't dictated by the power or amount of noise filtering, it's dictated by the wavelength of the carrier wave.

              HAM operates on bands between one and a couple thousand meters, thus their antennas have to be some sizable multiple of that (you can have full wave antennas for the shorter wavelengths, but extremely large elements are needed to even make a 1/4th wave antenna for the very large wavelengths).

              Cell signals, especially modern ones, by comparison, operate in the microwave bands, where wavelengths go from a few centimeters, to a few dozen millimeters (hence millimeter wave, in the case of 5g). The elements for a 1/2 wave or even full wave antenna are tiny, which is why cell phones no longer need big retractable antennas.

              Even on cell towers, the individual antenna elements are only a few centimeters long. They have a ton of them to allow them to do things like beamforming and MIMO to talk to multiple handsets at a time more easily, but they're not significantly more sensitive than the ones in cell phones. Remember, because cell phone communication is basically only possible with a two way signal, the trancievers on the phones also have to be good.

              To your second point, yes, cell communication is better tuned for downstream rather than upstream communication, but thats an intentional choice due to the nature of people's data usage. The typical consumer uses way more download than upload on the Internet. You see the same thing with DOCSIS cable model connections; they're asynchronous for the same reason, because it more closely matches consumers desires, not due to any fundamental limitations of the technology. You could make symmetrical cell connections just as easily as you could make symmetrical cable modem connections. There's a limited amount of EM spectrum in the universe though, so allocating more of it to download makes sense if your customers are doing more downloading. Duplex just means the connection is bidirectional, unlike broadcast radio which is simplex.

              1 vote
  2. [3]
    hoodnj
    Link
    Awesome write-up, thank you for sharing! Do you (or anyone else) know of any commercially available applications that are ready using this technology?

    Awesome write-up, thank you for sharing! Do you (or anyone else) know of any commercially available applications that are ready using this technology?

    2 votes
    1. Weldawadyathink
      Link Parent
      It’s not exactly the same thing, but the Philips hue WiFi bulbs and remotes use esp-now which is an api on top of ble for microcontrollers made by esp. the remote can have great battery life and...

      It’s not exactly the same thing, but the Philips hue WiFi bulbs and remotes use esp-now which is an api on top of ble for microcontrollers made by esp. the remote can have great battery life and communicate directly offline with the bulbs. I don’t know if the bulbs can be operated offline though.

      4 votes
    2. bkimmel
      Link Parent
      Chrome has a Web BLE API so you can (for Chrome only) make web apps that leverage the BLE "central" role.

      Chrome has a Web BLE API so you can (for Chrome only) make web apps that leverage the BLE "central" role.

      1 vote