Reading data on bluetooth device comes back as empty: react native bluetooth serial

Viewed 346

Here is a link from my last question about how to connect to a bluetooth classic device. How to check if any bluetooth device is connected in react native I'm now able to connect to the device and the listeners, such as onConnected, onDisconnected, enabled, disabled, all work, but I can't seem to figure out how to read the data from the bluetooth device. The device is this: http://www.senanetworks.com/sd1000-01.html

I've tried this on UseEffect:

BluetoothSerial.withDelimiter('\r').then(() => {
        Promise.all([
          BluetoothSerial.isEnabled(),
          BluetoothSerial.list()
        ])
        .then((values) => {
          const [ isEnabled, devices ] = values
          this.setState({ isEnabled, devices })
        })
    
        BluetoothSerial.on('bluetoothEnabled', () => console.log('Bluetooth enabled'))
        BluetoothSerial.on('bluetoothDisabled', () => console.log('Bluetooth disabled'))
        BluetoothSerial.on('read', (data) => {
    
           console.log(`DATA FROM BLUETOOTH: ${data.data}`);
           Toast.show(data.data);
       })
        BluetoothSerial.on('error', (err) => console.log(`Error: ${err.message}`))
        BluetoothSerial.on('connectionLost', () => {
          if (this.state.device) {
            console.log(`Connection to device ${this.state.device.name} has been lost`)
          }
          this.setState({ connected: false })
        })
      });

as well as just calling this:

BluetoothSerial.readFromDevice().then((data) => console.log(data))

The first code block is a listener for data, but it doesn't get any. The second code block is logging nothing, just emptiness. To note, the bluetooth device is connected to this printer: https://epson.com/For-Work/Printers/POS/TM-U295-Slip-Printer/p/C31C163292 and this meter: https://www.lcmeter.com/sites/default/files/EM100-11_%28LCRII%20Setup%20%26%20Operation%29.pdf

Any help will be appreciated. First time working with bluetooth devices.

0 Answers
Related