Bluetooth Low Energy is excellent for empowering local-first apps to achieve real-time performance while offline. It can be tricky to implement. However, by leveraging the principles of ad-hoc mesh networking, it is possible to achieve peer-to-peer data sync for applications even when they are inaccessible from the Internet.


Use Case: Local-First Apps

Problem Statement

Problem Statement


Today’s apps are entirely dependent on Internet availability, even for basic functioning. This calls for a new approach to networking that does not rely on a single point of Internet access to refresh the apps.

Realization Approach

Realization Approach


Inspired by the concept of mesh networking, other networking technologies such as BLE, which coexist with WiFi, can be utilized to provide alternative peer-to-peer connectivity for syncing apps in areas with poor WiFi coverage.

Solution Space

Solution Space


This technology is ideal for industrial workplaces with intermittent Internet access. It enables the establishment of an ad hoc edge network using BLE-based mesh technology, allowing seamless data sharing among co-workers and peer-to-peer data sync between enterprise applications.

Featured Networking Technology Platform

Ditto.live offers mobile ad-hoc mesh networking for web and mobile applications to enable peer-to-peer data sync for enterprise application. WIth a set of cross platform SDKs that support web, mobile, IoT, and server side apps, developers can easily leverage their technology to embed data sync capabilities at the edge, with or without the internet.

In a recent presentation at the /dev/world conference in Australia, Ditto.live showcased the potential of Bluetooth Low Energy (BLE) for peer-to-peer communication in mobile and cross-platform apps. Let’s look at how combining BLE with a local-first app architecture can create something truly revolutionary.

Local-First Apps and BLE

Today’s apps need Internet to perform all or a critical subset of their functionality. This isn’t always enough, though—if your work requires sending messages to a colleague or sharing data, you remain stuck until the server is available.

Local-first apps can perform their functions even without an active internet connection. BLE offers a solution. It enables devices physically near each other to communicate directly, ensuring seamless data sharing and real-time collaboration even when disconnected from Wi-Fi, local servers, or the cloud.

There are many use cases where this approach is suitable: flight attendants messaging and taking meal orders from passengers; maintenance workers in warehouses with poor WiFi coverage; outdoor hospitality venues; and restaurant employees who need to share orders with the kitchen display system when the internet goes down.

Core Concepts of BLE

BLE operates differently from regular WiFi networks, and understanding the differences is essential to using it effectively. There are two roles called central and peripheral, like clients and servers. The peripheral broadcasts advertisements on its radio. The central scans for those advertisements and initiates connections to peripherals.

A traditional BLE device performs only one of these roles, which can limit its usefulness. Modern phones and computers, however, can do both at once. This means any device can connect to any other device without relying on “leaders” or a single point of failure, like a WiFi access point. This can be extremely powerful for local-first applications, but it has to be implemented correctly.

Practical Tips for Implementing BLE

BLE is very capable, but achieving good performance, reliability, and security can be finicky. Ditto has overcome many challenges with respect to BLE, all of which are incorporated into Ditto’s SDK.


1. Advertisement Content: Choose service UUIDs and local names wisely to track devices running your app. You also need to use the manufacturer data field for cross-compatibility with Android.

2. Device Tracking: Since devices often rotate their MAC addresses for privacy, incorporate unique, app-generated identifiers for reliable tracking.

3. Security: BLE’s built-in security mechanisms are inconvenient. Implement application-level encryption using Mutual TLS or Noise Protocol for secure authentication and data transmission.

4. Handling L2CAP Channels: Dynamically allocated PSM values must be communicated to the central to create a channel via a characteristic or advertisement.

5. Connection Policies: Develop intelligent algorithms for determining which peers to connect with, considering advertisement frequency and avoiding duplication.

6. Background Modes: Switch on background modes to communicate while phones are locked, but be mindful of the limitations, such as reduced advertisement frequency and scanning intervals.

Cross-Platform Implementation

Ditto SDKs have complete cross-platform support in maintaining BLE support across various platforms (iOS, Android, Windows, and Linux). Developers can minimize code duplication across different operating systems by centralizing logic in a common core and using platform-specific drivers.

Conclusion

BLE offers a robust framework for building resilient, local-first apps with enhanced peer-to-peer communication capabilities. With the right strategies and understanding of BLE’s quirks, developers can create innovative applications that provide a seamless user experience, even without internet connectivity.

For more details and the complete presentation slides, watch the full presentation here.


This post was originally published in Ditto.live.

About the author 

Radiostud.io Staff

Showcasing and curating a knowledge base of tech use cases from across the web.

TechForCXO Weekly Newsletter
TechForCXO Weekly Newsletter

TechForCXO - Our Newsletter Delivering Technology Use Case Insights Every Two Weeks

>