TypeError: undefined is not a function (near '...device.monitorCharacteristicForService...')

466 views Asked by At

I'm trying to pull data from a glucose monitor. I've connected successfully and have the correct UUIDs for the relevant services and characteristics but I'm getting the error below:

TypeError: undefined is not a function (near '...device.monitorCharacteristicForService...')

Does anyone know why this might be? Code below shows the connecting function and the attempt to monitor the data. Both are being i nitiated by button presses.

Note I'm trying to run on android.

  const connectDevice = device => {
    manager.stopDeviceScan();
  manager.connectToDevice(device.id).then(async device => {
              await device.discoverAllServicesAndCharacteristics();
              manager.stopDeviceScan();
              setDisplayText(`Device connected\n with ${device.name}`);
              setConnectedDevice(device);
              setDevices([]);

              device.services().then(async service => {
                console.log(service)
              })

  }
  );
  }

  const getData = async device => { await
    device.monitorCharacteristicForService(
      '00001808-0000-1000-8000-00805f9b34fb', 
      '00002A18-0000-1000-8000-00805f9b34fb', 
      (error, characteristic) =>{
        if (error) {
          console.error("Error at receiving data from device", error);
          return;
        } else {
          console.log('Characteristic', characteristic)
        }},
  )};
0

There are 0 answers