Skip to content

trancee/capacitor-bitchat

Repository files navigation

@capacitor-trancee/bitchat

icon_128x128@2x

Bluetooth Mesh Network (Offline)

  • Local Communication: Direct peer-to-peer within Bluetooth range
  • Multi-hop Relay: Messages route through nearby devices (max 7 hops)
  • No Internet Required: Works completely offline in disaster scenarios
  • Noise Protocol Encryption: End-to-end encryption with forward secrecy
  • Binary Protocol: Compact packet format optimized for Bluetooth LE constraints
  • Automatic Discovery: Peer discovery and connection management
  • Adaptive Power: Battery-optimized duty cycling

https://github.com/permissionlesstech/bitchat https://github.com/permissionlesstech/bitchat-android

Install

npm install @capacitor-trancee/bitchat
npx cap sync

Configuration

These configuration values are available:

Prop Type Description Default Since
announceInterval number Sets the interval (in milliseconds) for announcing presence to nearby peers. 30000 (30 seconds) 0.1.4

Examples

In capacitor.config.json:

{
  "plugins": {
    "Bitchat": {
      "announceInterval": 10000
    }
  }
}

In capacitor.config.ts:

/// <reference types="@capacitor-trancee/bitchat" />

import { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  plugins: {
    Bitchat: {
      announceInterval: 10000,
    },
  },
};

export default config;

API

initialize(...)

initialize(options?: InitializeOptions | undefined) => Promise<InitializeResult>
Param Type
options InitializeOptions

Returns: Promise<InitializeResult>


isInitialized()

isInitialized() => Promise<IsInitializedResult>

Returns: Promise<IsInitializedResult>


start(...)

start(options?: StartOptions | undefined) => Promise<StartResult>
Param Type
options StartOptions

Returns: Promise<StartResult>


isStarted()

isStarted() => Promise<IsStartedResult>

Returns: Promise<IsStartedResult>


stop()

stop() => Promise<void>

establish(...)

establish(options?: EstablishOptions | undefined) => Promise<EstablishResult>
Param Type
options EstablishOptions

Returns: Promise<EstablishResult>


isEstablished(...)

isEstablished(options?: IsEstablishedOptions | undefined) => Promise<IsEstablishedResult>
Param Type
options IsEstablishedOptions

Returns: Promise<IsEstablishedResult>


send(...)

send(options: SendOptions) => Promise<SendResult>
Param Type
options SendOptions

Returns: Promise<SendResult>


checkPermissions()

checkPermissions() => Promise<PermissionStatus>

Returns: Promise<PermissionStatus>


requestPermissions(...)

requestPermissions(options?: Permissions | undefined) => Promise<PermissionStatus>
Param Type
options Permissions

Returns: Promise<PermissionStatus>


addListener('onStarted', ...)

addListener(eventName: 'onStarted', listenerFunc: OnStartedListener) => Promise<PluginListenerHandle>
Param Type
eventName 'onStarted'
listenerFunc OnStartedListener

Returns: Promise<PluginListenerHandle>


addListener('onStopped', ...)

addListener(eventName: 'onStopped', listenerFunc: OnStoppedListener) => Promise<PluginListenerHandle>
Param Type
eventName 'onStopped'
listenerFunc OnStoppedListener

Returns: Promise<PluginListenerHandle>


addListener('onFound', ...)

addListener(eventName: 'onFound', listenerFunc: OnFoundListener) => Promise<PluginListenerHandle>
Param Type
eventName 'onFound'
listenerFunc OnFoundListener

Returns: Promise<PluginListenerHandle>

Since: 0.1.3


addListener('onLost', ...)

addListener(eventName: 'onLost', listenerFunc: OnLostListener) => Promise<PluginListenerHandle>
Param Type
eventName 'onLost'
listenerFunc OnLostListener

Returns: Promise<PluginListenerHandle>

Since: 0.1.3


addListener('onConnected', ...)

addListener(eventName: 'onConnected', listenerFunc: OnConnectedListener) => Promise<PluginListenerHandle>
Param Type
eventName 'onConnected'
listenerFunc OnConnectedListener

Returns: Promise<PluginListenerHandle>


addListener('onDisconnected', ...)

addListener(eventName: 'onDisconnected', listenerFunc: OnDisconnectedListener) => Promise<PluginListenerHandle>
Param Type
eventName 'onDisconnected'
listenerFunc OnDisconnectedListener

Returns: Promise<PluginListenerHandle>


addListener('onEstablished', ...)

addListener(eventName: 'onEstablished', listenerFunc: OnEstablishedListener) => Promise<PluginListenerHandle>
Param Type
eventName 'onEstablished'
listenerFunc OnEstablishedListener

Returns: Promise<PluginListenerHandle>

Since: 0.1.5


addListener('onSent', ...)

addListener(eventName: 'onSent', listenerFunc: OnSentListener) => Promise<PluginListenerHandle>
Param Type
eventName 'onSent'
listenerFunc OnSentListener

Returns: Promise<PluginListenerHandle>


addListener('onReceived', ...)

addListener(eventName: 'onReceived', listenerFunc: OnReceivedListener) => Promise<PluginListenerHandle>
Param Type
eventName 'onReceived'
listenerFunc OnReceivedListener

Returns: Promise<PluginListenerHandle>


addListener('onPeerListUpdated', ...)

addListener(eventName: 'onPeerListUpdated', listenerFunc: OnPeerListUpdatedListener) => Promise<PluginListenerHandle>
Param Type
eventName 'onPeerListUpdated'
listenerFunc OnPeerListUpdatedListener

Returns: Promise<PluginListenerHandle>


addListener('onPeerIDChanged', ...)

addListener(eventName: 'onPeerIDChanged', listenerFunc: OnPeerIDChangedListener) => Promise<PluginListenerHandle>
Param Type
eventName 'onPeerIDChanged'
listenerFunc OnPeerIDChangedListener

Returns: Promise<PluginListenerHandle>

Since: 0.1.4


addListener('onRSSIUpdated', ...)

addListener(eventName: 'onRSSIUpdated', listenerFunc: OnRSSIUpdatedListener) => Promise<PluginListenerHandle>
Param Type
eventName 'onRSSIUpdated'
listenerFunc OnRSSIUpdatedListener

Returns: Promise<PluginListenerHandle>


removeAllListeners()

removeAllListeners() => Promise<void>

Interfaces

InitializeResult

Prop Type Since
peerID PeerID 0.1.1

InitializeOptions

Prop Type Default Since
announceInterval number 10000 (10 seconds) 0.1.4

IsInitializedResult

Prop Type
isInitialized boolean

StartResult

Prop Type Since
peerID PeerID 0.1.1

StartOptions

Prop Type Since
message Base64 0.1.1

IsStartedResult

Prop Type
isStarted boolean

EstablishResult

Prop Type Since
isEstablished boolean 0.1.5

EstablishOptions

Prop Type Since
peerID PeerID 0.1.5

IsEstablishedResult

Prop Type Since
isEstablished boolean 0.1.5

IsEstablishedOptions

Prop Type Since
peerID PeerID 0.1.5

SendResult

Prop Type
messageID MessageID

SendOptions

Prop Type
message Base64
peerID PeerID

PermissionStatus

Prop Type Description Since
bluetooth PermissionState BLUETOOTH_ADVERTISE Required to be able to advertise to nearby Bluetooth devices. BLUETOOTH_CONNECT Required to be able to connect to paired Bluetooth devices. BLUETOOTH_SCAN Required to be able to discover and pair nearby Bluetooth devices. BLUETOOTH Allows applications to connect to paired bluetooth devices. BLUETOOTH_ADMIN Allows applications to discover and pair bluetooth devices. 0.1.0
location PermissionState ACCESS_FINE_LOCATION Allows an app to access precise location. ACCESS_COARSE_LOCATION Allows an app to access approximate location. Android Only available for Android. 0.1.0
battery PermissionState REQUEST_IGNORE_BATTERY_OPTIMIZATIONS Allows an app to ignore battery optimizations. Android Only available for Android. 0.1.0

Permissions

Prop Type
permissions PermissionType[]

PluginListenerHandle

Prop Type
remove () => Promise<void>

OnStartedEvent

Prop Type Since
peerID PeerID 0.1.0
isStarted boolean 0.1.1

OnFoundEvent

Prop Type Since
peerID PeerID
message Base64 0.1.5

OnLostEvent

Prop Type
peerID PeerID

OnConnectedEvent

Prop Type
peerID PeerID

OnDisconnectedEvent

Prop Type
peerID PeerID

OnEstablishedEvent

Prop Type Since
peerID PeerID 0.1.5

OnSentEvent

Prop Type Since
messageID MessageID
peerID PeerID 0.1.2

OnReceivedEvent

Prop Type
messageID MessageID
message Base64
peerID PeerID

OnPeerListUpdatedEvent

Prop Type Since
peers ID[] 0.1.1

OnPeerIDChangedEvent

Prop Type Since
peerID PeerID 0.1.4
oldPeerID PeerID 0.1.5
message Base64

OnRSSIUpdatedEvent

Prop Type
peerID PeerID
rssi number

Type Aliases

PeerID

ID

ID

string & { readonly __brand: unique symbol }

Base64

string & { readonly __brand: unique symbol }

MessageID

UUID

UUID

string & { readonly __brand: unique symbol }

PermissionState

'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'

PermissionType

'bluetooth' | 'location' | 'battery'

OnStartedListener

(event: OnStartedEvent): void

OnStoppedListener

(event: void): void

OnFoundListener

(event: OnFoundEvent): void

OnLostListener

(event: OnLostEvent): void

OnConnectedListener

(event: OnConnectedEvent): void

OnDisconnectedListener

(event: OnDisconnectedEvent): void

OnEstablishedListener

(event: OnEstablishedEvent): void

OnSentListener

(event: OnSentEvent): void

OnReceivedListener

(event: OnReceivedEvent): void

OnPeerListUpdatedListener

(event: OnPeerListUpdatedEvent): void

OnPeerIDChangedListener

(event: OnPeerIDChangedEvent): void

OnRSSIUpdatedListener

(event: OnRSSIUpdatedEvent): void

About

Bluetooth Mesh Network (Offline)

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •