0

I successfully receive and read the data from BLE device using react-native-ble-plx library.

Listener receives the data every 10ms or 20ms but UI freezes ~1min afterwards.

What is the proper way to handle this scenario?

class DataReceiver extends React.Component {

  ...

  characteristicListener = async (error, characteristic) => {
    if (error) {
      // handle error
    } else {
      // read data
      //parse data/
      // add new data to data object
    }
  };
  
  startReadingData = async () => {
    ...
    
    action.monitorCharacteristic({
      serviceUUID: SERVICE_UUID,
      characteristicUUID: CHAR_UUID,
      listener: this.characteristicListener,
    });
    
    ...
  }

  render() {
     ...
  }
}

function mapStateToProps(state) {
  return {
    ...
  };
}

function mapDispatchToProps(dispatch) {
  return {
    action: bindActionCreators(
      {
        writeCharacteristic,
        monitorCharacteristic,
        readCharacteristic,
      },
      dispatch,
    ),
    dispatch,
  };
}

export default connect(mapStateToProps, mapDispatchToProps)(DataReceiver);
likeachamp
  • 765
  • 4
  • 11
  • 21
  • 1
    Having seen big trouble with simple iOS app using React Native, I'm inclined to reply: Stop using React Native. – meaning-matters Nov 27 '20 at 22:12
  • Are you still facing issues? Can you please tell me about your experience with BLE in ReactNative? – Arun Badole Apr 05 '21 at 15:19
  • @ArunBadole I was displaying some data based on listener so I believe that's the issue. It was trying to render the screen every 10-20ms. I am not 100% happy with BLE in ReactNative tbh but I don't have BLE experience in native development. So i cannot really compare. – likeachamp Apr 14 '21 at 21:38
  • @likeachamp Thanks for the update. Really appreciate. – Arun Badole Apr 27 '21 at 13:43

0 Answers0