You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I checked the documentation and FAQ without finding a solution
I checked to make sure that this issue has not already been filed
I'm sure that question is related to the library itself and not Bluetooth Low Energy or Classic in general. If that so, please post your question on StackOverflow.
I'm running the latest version
Question
I am able to connect to the device. Also monitorCharacteristicForDevice for device works for one serviceUUID and characteristicUUID but i want to get it working for 5 services and charecterisitcs. Is it possible to do using react-native-ble-plx library?
Question related code
const monitorMultipleCharacteristics = async () => {
try {
const monitorPromises = uuids.map(({ serviceUUID, characteristicUUID }) => { return new Promise((resolve, reject) => { BLEService.monitorCharacteristicForDevice( serviceUUID, characteristicUUID, async data => { case UUID: const temperature = parse(data.value) break case UUID: console.log('dispatch service') break default: console.log('Unknown UUID', data.uuid) } setTimeout(resolve, 100, data) console.info('success', new Date().getTime()) }, async error => { console.error(error) await BLEService.finishMonitor() reject() } ) // Store the subscription so it can be cleaned up later //subscriptions.push(subscription) }) // Wait for each monitor to be set up }) Promise.all(monitorPromises) .then(data => { console.log(data) }) .catch(error => { console.error('Error in one of the monitors:', error) })} catch (error) { console.error('Error setting up characteristic monitoring:', error)}// Optionally return the subscriptions if you need to stop monitoring later//return subscriptions
}
The text was updated successfully, but these errors were encountered:
smitha-2020
changed the title
Is it possible to monitor multiple services of 'notify type' for a device
Is it possible to subscribe to multiple services of 'notify type' for a device
Oct 28, 2024
smitha-2020
changed the title
Is it possible to subscribe to multiple services of 'notify type' for a device
Is it possible to subscribe to multiple service characteristics of 'notify type' for a device
Oct 31, 2024
Yes, it is. Please remember that if you use Promise, it will resolve only once according to the contract. That's why monitorCharacteristic is callback based.
Prerequisites
Question
I am able to connect to the device. Also monitorCharacteristicForDevice for device works for one serviceUUID and characteristicUUID but i want to get it working for 5 services and charecterisitcs. Is it possible to do using react-native-ble-plx library?
Question related code
The text was updated successfully, but these errors were encountered: