Skip to main content

Installation

Install the Package

npm install @offline-protocol/mesh-sdk

Linking

You need to link the native modules next.

iOS

  1. Podfile (ios/Podfile)
Add the pod:
target 'YourAppName' do
  use_expo_modules!
  
  # add MeshSdk 
  pod 'MeshSdk', :path => '../node_modules/@offline-protocol/mesh-sdk/ios'
end
Then run:
cd ios && pod install

Android

  1. settings.gradle (android/settings.gradle)
Add the module include:
include ':app'
include ':mesh-sdk'
project(':mesh-sdk').projectDir = new File(rootProject.projectDir, '../node_modules/@offline-protocol/mesh-sdk/android')
  1. app/build.gradle (android/app/build.gradle)
Add the dependency:
dependencies {
    implementation("com.facebook.react:react-android")
    
    implementation project(':mesh-sdk')
}
  1. MainApplication.kt (android/app/src/main/java/com/yourpackage/YourApp/MainApplication.kt)
Add the import and register the package:
import com.offlineprotocol.OfflineProtocolPackage

// Inside getPackages():
override fun getPackages(): List<ReactPackage> =
    PackageList(this).packages.apply {
      add(OfflineProtocolPackage())
    }

Platform Setup

iOS Permissions

Add the following to your Info.plist:
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Required for offline mesh communication</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>Required for offline mesh communication</string>
<key>UIBackgroundModes</key>
<array>
    <string>bluetooth-central</string>
    <string>bluetooth-peripheral</string>
</array>

Android Permissions

Add the following to your AndroidManifest.xml:
<!-- Bluetooth (Android 12+) -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

<!-- Bluetooth (Android 11 and below) -->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<!-- WiFi Direct -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.NEARBY_WIFI_DEVICES" />

<!-- Internet -->
<uses-permission android:name="android.permission.INTERNET" />

Next Steps

Set up the SDK in your app