React-Native get data through Bluetooth

// Expert user has replied.
J Joris Thalamas 7 months 1 week ago
827 6 2


Hello,

I'm currently developping a react-native app which need to read Barcode, QrCode and RFID tags.

It need to support various scanner. Currently I'm trying to use a RFD40 premium plus and a RFD85 within the app.

I use the react-native-bluetooth-classic module to.

So far I manage to connect both of the devices to the app.

The issue is that I don't manage to get the data from the scanner. When I perform a RFID scan nothing happen and when I scan a barcode or QrCode the scanner emit 1 bip with a green light then a few seconds later it emit 4 bips with a red light (one light peer bip).

In my code, when I use the method onDataReceived wich should trigger as soon as I scan something nothing happend and when I use the method read and available it seems to have no data.

I someone any idea of why I don't manage to get data and what does these 4 bips means ?

Best Regards

Please register or login to post a reply

6 Replies

J Joris Thalamas

Here a sample of my code :

let readInterval = null;
let device = null;
 
async function startDiscovery() {
    try {
      console.log('startDiscovery');
      let unpaired = await RNBluetoothClassic.startDiscovery();
      for (const unpairedDevice of unpaired) {
        if (unpairedDevice .name === 'RFD40+_22249520100906') {
          device = unpairedDevice;
          try {
            await device.connect();
            readInterval = setInterval(() => performRead(), 5000);
            //sub = device.onDataReceived((data) => onReceivedData(data));
          } catch (err) {
            console.error('sub', err);
          }
        }
      }
    } catch (err) {
      console.error(err);
    }
  }

 async function performRead() {
    try {
      console.log('Polling for available messages');
      let available = await device.available();
      console.log(`There is data available [${available}], attempting read`);
      if (available > 0) {
        for (let i = 0; i < available; i++) {
          console.log(`reading ${i}th time`);
          let data = await device.read();
          console.log(`Read data ${data}`);
        }
      }
    } catch (err) {
      console.log(err);
    }
  }

 

J Joris Thalamas

Ok after many trial I manage to get the data from BarCode and QrCode using :

await device.connect({
  connectionType: 'binary',
});

The issues are :

  • After scanning a barcode or qrcode I need to wait for the 4 bips to scan again (wich take a few seconde)
  • I still don't manage to perform a RFID scan
S Sean Kennedy

The RFID support for Bluetooth is Interactive with the RFID API3 Libraries - this is not available as a Bluetooth Classic SPP profile only - this is not supported.

If you wish to have RFID / Barcode Data from the RFD8500 / RFD40 and you do not wish to use the RFID API3 SDK - you will need to configure the RFD devices as Bluetooth HID interface devices - and you will lose a lot of Capability (NO RFID Transactions - only read-only data.

The RFD40 RFID SDK for the Handheld RFID Sled is found on the RFD40 Support portal.

S Sean Kennedy

If you choose to use the RFID API3 and Scanner control Framework by using the Android Studio - version of the RFID SDK for the RFD40 platform, you gain a lot of features for Both Barcode Support as well as for RFID Support.

Zebra does not have plans to support 3rd party Development Frameworks (Flutter, React, and Cordova).

Zebra Supports Java based Android Studio development, and Xamarin Forms (not Maui at the moment) for RFID API3 and Scanner Framework for RFD sled.

J Joris Thalamas

Hello,

Thank you so much Sean, your answer was really helpfull. I integrated the RFID API13 in our app and manage to read our RFID tags on android side (IOS will be done later).

Now I'm trying to read barcode. If I understand correctly to read barcode, I need to use the Scanner sdk or is it possible to use the RFID API13 too ?

If I have to use the Scanner sdk, could you please help me to understand which class in the android_scanner_sdk_demo_v2.6.19.0_src I should look for ? I have trouble to identify what is helpful or not (I'm looking how to get device list, connect/disconnect and read tag).

If I can use RFID API13 (which I would prefer) could you please help me understand how to do it ? So far the only thing I found about bar code is :  com.zebra.rfid.api3.Config.setTriggerMode(ENUM_TRIGGER_MODE.BARCODE_MODE, true) but my event handler don't detect when a barcode is scanned.

Thank you in advance

J Joris Thalamas

Ok I found my answer, the scanner sdk is included in RFID API13, so I need to implement either RIFID scan handler or Barcode scan handler (using IDcsSdkApiDelegate) depending on the device mode.

I would like to know if it's possible to detect the mode change. For example is it possible to detect on a RFD85 if the user press the mode button ? Or on RFD40 if it's possible to detect if the user press the lower trigger ? Is there any event in either com.zebra.rfid or com.zebra.scannercontrol (I don't manage to find it) ? 

CONTACT
Can’t find what you’re looking for?