This is React Native Bluetooth Low Energy library using RxBluetoothKit and RxAndroidBle under the hood.
scanAndConnect() {
this.manager = new BleManager();
// Wait for PoweredOn state
this.manager.startDeviceScan(null, null, (error, device) => {
if (error) {
return;
}
// Check if it is a device you are looking for based on advertisement data
// or other criteria.
if (device.name === 'TI BLE Sensor Tag' ||
device.name === 'SensorTag') {
// Stop scanning as it's not necessary if you are scanning for one device.
this.manager.stopDeviceScan();
// Proceed with connection.
device.connect()
.then((device) => {
return device.discoverAllServicesAndCharacteristics()
})
.then((device) => {
// Do work on device with services and characteristics
})
.catch((error) => {
// Handle errors
});
}
});
}
Damnit, now I want to take on a new React Native project where I can use this library 😅
react-native-ble-plx
(GitHub) →react-native-ble-plx
Documentation →
Buy an ESP32 and connect some LED lights 🙂 Works great!
Is there any example for UI for what you worked on?