3

I have a react native project that is suppose to print a ticket using a little Bluetooth printer. In order to access bluetooth functionality I'm using react-native-ble-plx library.

My question is, once I connect to the device, how do I send the information to the printer? I have no idea from where I'm supposed to get the characteristicUUID and serviceUUID. I have my doubts with my code, here is what I have so far:

(() => {
  bleManager.startDeviceScan(null, null, (error, device) => {
    console.log("Scanning...");
    if (error) {
      console.log(error);
      return;
    }

    if (device.name === "XXZEJ183806056") {
      console.log("Conectando a impresora...");
      bleManager.stopDeviceScan();

      device.connect()
        .then((device) => {
          console.log("Descubriendo servicios y caracteristicas...");
          return device.discoverAllServicesAndCharacteristics();
        })
        .then((device) => {
          console.log("Conectado a: ", device.id);
          device.writeCharacteristicWithResponseForService(...);
        })
        .catch((error) => {
          console.log("error", error.message);
        });
    }
  });
})();

0 Answers0