BluetoothSerial.write("SomeText") 不工作(React Native 和 react-native-bluetooth-serial)

BluetoothSerial.write("SomeText") not working (React Native and react-native-bluetooth-serial)

我正在通过 React Native 应用程序和 [= 进行蓝牙串行连接56=]。我在我的项目中使用 react-native-bluetooth-serial-2 npm 包来建立蓝牙串行连接。

到目前为止连接已经建立,数据从Raspberry Pi到我的React Native 应用正在 sent.I 正在使用此代码接收数据:

BluetoothSerial.on('read', (data) => {
  console.log(data);
});
BluetoothSerial.withDelimiter('\n').then(() => {
  console.log('Bluetooth subscribed with delimiter');
});

但是当我尝试将数据从我的 React Native 应用程序发送到 Raspberry Pi 使用 BluetoothSerial.write("SomeText") 似乎没有任何效果。

我什至试过这个功能:

BluetoothSerial.write(
  'start',
  (success) => {
    console.log('Connection Successful!!: ', success);
  },
  (failure) => {
    console.log('Connection Failure!!: ', failure);
  },
);

看看我是否得到任何失败的结果,即使那没有用。

有人可以帮我解决这个问题吗!!

谢谢!!

糟糕,我只需要在 BluetoothSerial.on('read', (data) => { console.log(data); }); 函数中调用 BluetoothSerial.write()

谢谢!!