npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-nexstem-companion-app-client

v2.2.17

Published

This is a package to communicate with nexstem headset via ble

Downloads

110

Readme

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