Bluetooth mesh messaging SDK for apps

Overview

Berkanan SDK Tweet

build Contributions Contributor Covenant

Berkanan SDK enables Bluetooth mesh messaging between nearby apps. It's the framework used by Berkanan Messenger (Product Hunt, TechCrunch) and Berkanan Messenger Lite (GitHub).

The goal is to create a decentralized mesh network for the people, powered by their device's Bluetooth antenna. People could rely on this network for texting in situations, like emergencies, when there's no other connectivity available — it could literally save lives.

With Berkanan SDK, apps can discover nearby apps, which also have the SDK integrated and Bluetooth turned on, and send them small messages. The range for these messages is about 70 meters, but they can reach further because the SDK automatically resends them upon receiving. The more apps use Berkanan SDK, the further the reach of the messages gets.

Features and Limitations

  • Free and open-source: Contributions are welcome!
  • Bluetooth-powered: No need for Wi-Fi or cellular connectivity.
  • Background: On iOS, it works even while in the background. However, background-running apps can't discover each other — the system enforces this policy.
  • Connectionless communication with no pairing, no sessions, and no limit on the number of apps.
  • For sending messages, the SDK uses flooding, where duplicates are filtered by tracking their identifiers and decreasing their time to live (TTL) by 1, until they reach 0, as they travel from app to app.
  • The message range limit between two devices is about 70 meters.
  • The data size limit is 512 bytes.
  • No built-in support for encryption, acknowledgment, or store and forward. You have to roll your own if your use case requires it.
  • It's not a Bluetooth Mesh Networking implementation.
  • Supported operating systems: iOS 9.0 or later, watchOS 4.0 or later, tvOS 9.0 or later, macOS 10.13 or later.

Privacy Policy

Berkanan SDK does not send the messages to any central server or company.

Integrating Berkanan SDK into your app

iOS

To integrate Berkanan SDK into your iOS app, use Xcode 11 or later. Open the .xcodeproj or .xcworkspace file of your app and follow these steps.

Configuring your app target

Select your app target and then go to Editor / Add Capability / Background Modes. Check both Uses Bluetooth LE accessories and Acts as a Bluetooth LE accessory.

Go to Signing & Capabilities / App Sandbox and check the Bluetooth checkbox.

Add NSBluetoothAlwaysUsageDescription and NSBluetoothPeripheralUsageDescription to the Info.plist with the value:

Allow access to the Berkanan Bluetooth Service to be able to communicate even while offline.

Adding Berkanan SDK to your app

Go to File / Swift Packages / Add Package Dependency... and enter https://github.com/zssz/BerkananSDK.git

Add @import BerkananSDK to your source files where needed.

Using Berkanan SDK in your app

Initializing a local service with a configuration to advertise
let configuration = Configuration(
  // The identifier is used to identify what kind of configuration the service has. 
  // It should be the same across app runs.
  identifier: UUID(uuidString: "3749ED8E-DBA0-4095-822B-1DC61762CCF3")!, 
  userInfo: "My User Info".data(using: .utf8)!
)
// Throws if the configuration is too big or invalid.
let localService = try BerkananBluetoothService(configuration: configuration)
Starting a local service
localService.start()
Discovering nearby services and their advertised configuration
let discoverServiceCanceller = localService.discoverServiceSubject
  .receive(on: RunLoop.main)
  .sink { remoteService in
    print("Discovered \(remoteService) with \(remoteService.getConfiguration())")
}
Constructing a message with a payload type identifier and payload
let message = Message(
  // The payloadType is used to identify what kind of payload the message carries.
  payloadType: UUID(uuidString: "E268F3C1-5ADB-4412-BE04-F4A04F9B3D1A")!,
  payload: "Hello, World!".data(using: .utf8)
)
Sending a message
// Throws if the message is too big or invalid.
try localService.send(message)
Receiving messages
let receiveMessageCanceller = localService.receiveMessageSubject
  .receive(on: RunLoop.main)
  .sink { message in
    print("Received \(message.payloadType) \(message.payload)")
}
Stopping the local service
localService.stop()

Sample app

To see how Berkanan Messenger Lite app integrates Berkanan SDK, check out its source code.

You might also like...
Fluetooth - Flutter library for sending bytes to Bluetooth devices on Android/iOS

A Flutter library for sending bytes to Bluetooth devices. Available on Android a

MiniVendingMachine - SwiftUI demo Apple Watch app to open a mini vending machine via bluetooth

Mini Vending Machine Use Apple Watch to open vending machine cells. Note: This a

The Bluetooth LE library for iOS and Mac. 100% Swift.
The Bluetooth LE library for iOS and Mac. 100% Swift.

iOS-BLE-Library An in-development Bluetooth Low Energy Library by Nordic Semiconductor to interact with the , which is not complicated, but requires w

An open-source Swift framework for building event-driven, zero-config Multipeer Connectivity apps

PeerKit An open-source Swift framework for building event-driven, zero-config Multipeer Connectivity apps Usage // Automatically detect and attach to

Bluetooth LE Mesh Chat for iOS and Android

BLEMeshChat Bluetooth LE mesh chat prototype for iOS. Android version over here. Goals Use the Bluetooth 4.0 Low Energy APIs on iOS and Android to all

A Flutter powered messaging app including Firebase registration, authentication and group messaging feature.

we_chat A Flutter powered messaging app including Firebase registration, authentication and group messaging feature. Getting Started This project is a

BLE (Bluetooth LE) for U🎁 Bleu is the best in the Bluetooth library.
BLE (Bluetooth LE) for U🎁 Bleu is the best in the Bluetooth library.

Bleu Bleu is a Bluetooth library. Bleu is the easiest way to operate CoreBluetooth. Bleu is possible to operate by replacing Bluetooth 's Peripheral a

MetaWear-Swift-Combine-SDK - Build iOS and macOS apps controlling MetaWear Bluetooth Low Energy wearables without C++ or CoreBluetooth expertise
A powerful and easy to use live mesh gradient renderer for iOS.

MeshKit A powerful and easy to use live mesh gradient renderer for iOS. This project wouldn't be possible without the awesome work from Moving Parts a

A simple mesh viewer for MacOS based on Swift and Metal and using Assimp for loading meshes

Metal Mesh Viewer A simple triangle mesh viewer for MacOS This application is a simple (triangle) mesh viewer that should be capable of rendering even

ARKit: Projecting 3D mesh to 2D coordinate
ARKit: Projecting 3D mesh to 2D coordinate

ARKitDemo ARKit: Projecting 3D mesh to 2D coordinate A simple utility to project 3D face mesh in 2D coordinate on device screen. Sources: https://deve

An auto growing text input bar for messaging apps.
An auto growing text input bar for messaging apps.

ALTextInputBar An auto growing text input bar for messaging apps. Written in Swift. ALTextInputBar is designed to solve a few issues that folks usuall

Bluejay is a simple Swift framework for building reliable Bluetooth LE apps.
Bluejay is a simple Swift framework for building reliable Bluetooth LE apps.

Bluejay is a simple Swift framework for building reliable Bluetooth LE apps. Bluejay's primary goals are: Simplify talking to a single Bluetooth LE pe

A simple Swift framework for building reliable Bluetooth LE apps.
A simple Swift framework for building reliable Bluetooth LE apps.

Bluejay is a simple Swift framework for building reliable Bluetooth LE apps. Bluejay's primary goals are: Simplify talking to a single Bluetooth LE pe

Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.
Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.

Themis provides strong, usable cryptography for busy people General purpose cryptographic library for storage and messaging for iOS (Swift, Obj-C), An

iOS - Real-time messaging app  🎨
iOS - Real-time messaging app 🎨

General mChat is a real-time messaging app written in Swift for iOS devices. Since mChat uses a fast and reliable Firebase Database, it receives data

A collaborative Augmented Reality iOS experience using Real-time Messaging

Collaborative AR Experience This project creates an augmented reality experience where you can build a scene together with anyone around the world, se

Open-Source Messaging App
Open-Source Messaging App

Acani Chats Open-Source Native iOS Messages App This project and its submodules no longer work and are no longer being maintained. Acani Chats is an i

Open-Source Messaging App
Open-Source Messaging App

Acani Chats Open-Source Native iOS Messages App This project and its submodules no longer work and are no longer being maintained. Acani Chats is an i

Comments
  • Installation...

    Installation...

    followed everything upto... Add @import BerkananSDK to your source files where needed.

    obviously this is important as the rest doesnt work even though i got the dependency... where is the source file? where do i do the import import BerkananSDK doesnt work in ViewController please advice thx! tami

    opened by fire17 0
Owner
Zsombor Szabo
Zsombor Szabo
Bluejay is a simple Swift framework for building reliable Bluetooth LE apps.

Bluejay is a simple Swift framework for building reliable Bluetooth LE apps. Bluejay's primary goals are: Simplify talking to a single Bluetooth LE pe

Steamclock Software 1k Dec 13, 2022
iOS Bluetooth LE framework

Features A futures interface replacing protocol implementations. Timeout for Peripheral connection, Service scan, Service + Characteristic discovery a

Troy Stribling 696 Dec 25, 2022
RxBluetoothKit is a Bluetooth library that makes interaction with BLE devices much more pleasant.

RxBluetoothKit is a Bluetooth library that makes interaction with BLE devices much more pleasant. It's backed by RxSwift and CoreBluetooth and it prov

Polidea 1.3k Jan 6, 2023
Omnipod Bluetooth PumpManager For Loop

OmniBLE Omnipod Bluetooth PumpManager For Loop Status This module is at the very beginning stages of development and does not even compile yet. DO NOT

Randall Knutson 20 Apr 21, 2022
Build your own 'AirTags' 🏷 today! Framework for tracking personal Bluetooth devices via Apple's massive Find My network.

OpenHaystack is a framework for tracking personal Bluetooth devices via Apple's massive Find My network.

Secure Mobile Networking Lab 5.8k Jan 9, 2023
Diabetes: test the FreeStyle Libre glucose sensor as a Bluetooth Low Energy device, even directly from an Apple Watch.

Since the FreeStyle Libre 2 / 3 glucose sensors are Bluetooth Low Energy devices, I am trying to leverage their capabilities to implement something ne

Guido Soranzio 6 Jan 2, 2023
Simple, block-based, lightweight library over CoreBluetooth. Will clean up your Core Bluetooth related code.

LGBluetooth Simple, block-based, lightweight library over CoreBluetooth. Steps to start using Drag and Drop it into your project Import "LGBluetooth.h

null 170 Sep 19, 2022
Bluetooth mapping in Swift

Bluetonium is part of the E-sites iOS Suite. Bluetonium is a Swift Library that makes it easy to communicate with Bluetooth devices. Features ?? Servi

E-sites 165 Nov 20, 2022
The easiest way to use Bluetooth (BLE )in ios,even bady can use.

The easiest way to use Bluetooth (BLE )in ios,even bady can use.

刘彦玮 4.6k Dec 27, 2022
Blocks Based Bluetooth LE Connectivity framework for iOS/watchOS/tvOS/OSX. Quickly configure centrals & peripherals, perform read/write operations, and respond characteristic updates.

ExtendaBLE Introduction ExtendaBLE provides a very flexible syntax for defining centrals and peripherals with ease. Following a blocks based builder a

Anton 94 Nov 29, 2022