This is a package to communicate with nexstem headset via ble
npm install react-native-nexstem-companion-app-clientThe 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.
Update your AndroidManifest.xml file to include the necessary permissions for BLE communication:
``xml
package="YOUR_PACKAGE_NAME">
`
``
`
import { BleBasicCustom } from 'react-native-nexstem-companion-app-client';
`$3
Initialize BleManger after creating BleBasicCustom instance.
``
BleBasicCustom.bleManager.start({ showAlert: false });
BleBasicCustom.bleManager.enableBluetooth();
`$3
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()
`$3
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)
`$3
Stop the device scan __BleBasicCustom.stopScan__`
await BleBasicCustom.stopScan()
`$3
Pair with a device, for IOS ask the use to pair manually from settings.`
await BleBasicCustom.pairWithDevice(peripheralId: "")
`
$3
Gets paired devices, returns a list of Peripherals (instances of peripherals).`
await BleBasicCustom.getBondedDevices()
`
$3
`
await BleBasicCustom.disconnectDevice(peripheralId: "")
`$3
`
await BleBasicCustom.getDistanceInMetres(peripheralId: "")
`$3
`
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
``