2

I'm having trouble with the monitorCharacteristicForService function in react-native-ble-plx. I want to stop the monitoring, but I don't seem to get it. Here is my code :

const getNumberOfTrames = async(device)=>{
    await device.writeCharacteristicWithResponseForService(serviceUUID, writeUUID, 'IzA5') 
    
    const monitorNumber = device.monitorCharacteristicForService(serviceUUID, readUUID, (error, a) => {

      if (error) {
        console.log('err',error)
        console.log('err',error.message)
      } else {
        console.log(base64.decode(a.value))
      }
    }, 'idMonitorNumber')

    return () => {
      console.log('REMOVED')
      monitorNumber.remove();
    }
  }

REMOVED is never printed on my console, even when I deconnect my bluetooth... I also tried with bleManager.cancelTransaction('idMonitorNumber') but it doesn't do anything either.

For information, I just call my function getNumberOfTrameswhen I press a button, but I have no other interaction with it. Maybe I need to say somewhere 'call the return function of getNumberOfTrames' ?

Can someone help me please ?

Boonty
  • 63
  • 7

0 Answers0