1.1.10 • Published 11 days ago

react-native-nexstem-companion-app-client v1.1.10

Weekly downloads
-
License
MIT
Repository
github
Last release
11 days ago

React Native Nexstem Companion App Client

The React Native Nexstem Companion App Client is a Bluetooth Low Energy (BLE) communication interface for both Android and iOS platforms. It facilitates seamless interaction NexStem headset and also provied abstractions to communicate and experiment ble comm. with headset.

Permissions and Manifest Updates

Android Manifest Updates

Update your AndroidManifest.xml file to include the necessary permissions for BLE communication:

<!-- Add xmlns:tools -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="YOUR_PACKAGE_NAME">

    <!-- HACK: Permission for BLE on Android 12+ devices -->
    <uses-permission android:name="android.permission.BLUETOOTH" tools:remove="android:maxSdkVersion" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" tools:remove="android:maxSdkVersion" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="28"/>
    <uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30"/>
    <!-- Additional permissions when targeting Android 12 or higher -->
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN"
                     android:usesPermissionFlags="neverForLocation" />
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
    <!-- Include other permissions as needed -->

    <!-- ... -->

</manifest>

IOS podfile Updates

<key>NSBluetoothAlwaysUsageDescription</key>
<string>Your description for Bluetooth usage</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>Your description for Bluetooth peripheral usage</string>

Usage

Import the library

import { BleBasicCustom } from 'react-native-nexstem-companion-app-client';

Initialize BleManger

Initialize BleManger after creating BleBasicCustom instance.

BleBasicCustom.bleManager.start({ showAlert: false });

Enable Bluetooth Android Only

Create the request to the user to activate the bluetooth. Returns a Promise object.

BleBasicCustom.bleManager.enableBluetooth();

Check Bluetooth State

Force the module to check the state of the native BLE manager and trigger a BleManagerDidUpdateState event. Resolves to a promise containing the current BleState.

await BleBasicCustom.bleManager.checkState()

Start the device scan

Start the scan and to receive devices pass deviceFoundHandler callback in constructor of BleBasicCustom.scanForDevices

Returns instance of Peripheral which is caught by listener deviceFoundHandler. .

await BleBasicCustom.scanForDevices(5)

Stop device scan

Stop the device scan BleBasicCustom.stopScan

await BleBasicCustom.stopScan()

Pair with device Android Only

Pair with a device, for IOS ask the use to pair manually from settings.

await BleBasicCustom.pairWithDevice(peripheralId: "")

Get Paired Devices Android Only

Gets paired devices, returns a list of Peripherals (instances of peripherals).

await BleBasicCustom.getBondedDevices()

Disconnect from Device

await BleBasicCustom.disconnectDevice(peripheralId: "")

Get distance from Device

await BleBasicCustom.getDistanceInMetres(peripheralId: "")

Perform a cleanup before reinitializing BleBasicCustom class.

BleBasicCustom.cleanup(peripheralId?: string): void 

Note

HeadsetManager contains instance of BleBasicCustom, you can use it directly to communicate instead of creating a new BleBasicCustom instance again if you are using HeadsetManager instance.

Headset Manager Initialization

const headsetManager = new HeadsetManager(handleDeviceFound);


// Methods
// Get CPU Information
headsetManager.getCPUInfo();

// Get Electrode Information
headsetManager.getElectrodeInfo();

// Get Available WiFi Connections
headsetManager.getAvailableWifiConnections();

// Get My WiFi Connections
headsetManager.getMyWifiConnections();

// Connect to WiFi
const ssid = 'your_wifi_ssid';
const password = 'your_wifi_password';
headsetManager.connectToWifi(ssid, password);

// Disconnect from WiFi
headsetManager.disconnectFromWifi();

// Get Settings Device Information
headsetManager.getSettingsDeviceInfo();

// Get Settings Update Information
headsetManager.getSettingsUpdateInfo();

// Get Settings Update Status
headsetManager.getSettingsUpdateStatus();

// Get Battery Percentage
headsetManager.getBatteryPercentage();

Headset Event Handling

headsetManager.events.onBatteryPercentage((data) => {
  // Handle battery percentage data
});

headsetManager.events.onElectrodeInfo((data) => {
  // Handle electrode information data
});

// Add listeners for other events as needed
1.1.10

11 days ago

1.1.9

12 days ago

1.1.8

13 days ago

1.1.7

13 days ago

1.1.6

13 days ago

1.1.1

14 days ago

1.1.0

14 days ago

1.1.5

14 days ago

1.1.4

14 days ago

1.1.2

14 days ago

1.0.9

17 days ago

1.0.8

17 days ago

1.0.6

17 days ago

1.0.5

1 month ago

1.0.2

1 month ago

1.0.1

1 month ago

0.9.8

1 month ago

1.0.0

1 month ago

0.9.9

1 month ago

0.9.7

1 month ago

0.9.6

2 months ago

0.9.5

2 months ago

0.9.4

4 months ago

0.9.3

5 months ago

0.9.0

5 months ago

0.9.2

5 months ago

0.9.1

5 months ago

0.8.0

5 months ago

0.7.1

5 months ago

0.7.0

5 months ago

0.5.0

5 months ago

0.6.0

5 months ago

0.3.0

5 months ago

0.4.0

5 months ago

0.2.0

5 months ago

0.1.1

5 months ago

0.1.0

5 months ago