star-micronics / react-native-star-io10

react-native-star-io10 is a library for supporting application development for Star Micronics devices.
Other
88 stars 54 forks source link

Scanning bluetooth with IOS #8

Closed kmamtora closed 2 years ago

kmamtora commented 3 years ago

I have scanning bluetooth printers code that works well for android but for ios it doesnt give any error nor it finds bluetooth devices here is my code ` try { await this._manager?.stopDiscovery();

  var interfaceTypes = [];

  interfaceTypes.push(InterfaceType.Bluetooth);

  this._manager = await StarDeviceDiscoveryManagerFactory.create(
    interfaceTypes,
  );
  this._manager.discoveryTime = 10000;

  this._manager.onPrinterFound = (printer) => {
    const printers = this.state.printers;

    console.log(`Found printer: ${printer.connectionSettings.identifier}.`);
  };

  this._manager.onDiscoveryFinished = async () => {
    console.log(`Discovery finished.`);

  };

  await this._manager.startDiscovery();
} catch (error) {
  console.log(`Error: ${String(error)}`);
}

`

gare-bear commented 3 years ago

@kmamtora after the npm install, theres a few steps that must be done in Xcode which are documented here. Can you confirm you've done that?

kmamtora commented 3 years ago

@gare-bear Yes I have already executed this steps

Screen Shot 2021-04-16 at 10 39 30 AM

kmamtora commented 3 years ago

Any update on this ?

gare-bear commented 3 years ago

@kmamtora i'm looking into it. Can you tell me which printer you're targeting? iOS has different Bluetooth requirements than Android; mainly products must be paired and MFi certified, so if you're not paired or using a product that is not MFi certified it could it could impede your ability to discover it.

kmamtora commented 3 years ago

mPop, TSP100 and MCP31C BK US, this are the models which I have and have tried with mPop which is not working

gare-bear commented 3 years ago

@kmamtora iOS has a strict 1-1 pairing requirement, any chance the printer is paired with another device? I also suggest testing the printer with our mPOP utility and see if its detected.

Seems more like a connectivity issue than a code issue.

gare-bear commented 3 years ago

@kmamtora were you able to resolve this issue?

dillondrobena commented 2 years ago

Also having a similar issue with an mPop drawer/printer combo. The mPop utility discovers it fine, but not my code. If I connect directly to the printer through bluetooth the code scanning picks it up, otherwise it doesn't show anything

gare-bear commented 2 years ago

@dillondrobena You have to pair the printer prior to use, this SDK won't be able to discover it otherwise. The mPOP Utility is not a react native app, it is a native Swift app using our StarPRNT SDK for iOS. The APIs are different and the StarPRNT SDK can discover nearby Bluetooth printers, even when not connected.

dillondrobena commented 2 years ago

@gare-bear I suppose there's not a react-native port for the StarPRNT SDK for iOS correct? If I wanted to make use of the Bluetooth scanning the SDK provides I'll have to write my own module?

gare-bear commented 2 years ago

@dillondrobena That's right. The good thing is, the code is not unique to Star. Its using the EAAccessoryManager to show the BluetoothAccessoryPicker. This isn't in the Xpand SDK, but as you said you could write your own module.

One additional point, from my experience this approach doesn't play nice with with devices that use PIN code based pairing methods. Thankfully most Star printers now use SSP (Secure Simple Pairing) and can work with this approach.