Giter VIP home page Giter VIP logo

react-native-star-io10's Introduction

react-native-star-io10

react-native-star-io10 is a library for supporting application development for Star Micronics devices.

This library is included in StarXpand SDK.

Documentation

Please refer here for StarXpand SDK documentation.

Documentation includes an overview of the SDK, how to build a sample application, how to use the API, and a API reference.

Requirements

Platform Version Arch
iOS iOS 13.0 or later Device: arm64
Simulator: x86_64, arm64
Android Android 9.0 or later arm64-v8a, armeabi-v7a, x86, x86_64
Windows Windows 11 / Windows 10 22H2 x86, x64

Installation

npm install react-native-star-io10 --save

iOS

Privacy manifest file

In accordance with Apple's guidelines, react-native-star-io10 V1.6.1 or later includes a privacy manifest file. Please see here for the Manifest file. However, react-native-star-io10 does not use the Required Reason API from the first release. (As of January 29, 2024)

Some settings and approvals are required depending on the printer interface

Please check the table below and take action.

Interface of the printer Necessary actions
Bluetooth 1. & 2. & 4.
Bluetooth Low Energy 2.
Ethernet (iOS14 or later) 3.
Lightning USB 1. & 4.

1. Set Supported external accessory protocols
  1. Click on the information property list file (default : “Info.plist”).
  2. Add the Supported external accessory protocols Key.
  3. Click the triangle of this key and set the value for the “Item 0” to jp.star-m.starpro.

⚠️ If you do not use the printer concerned, do not configure this setting.

2. Set Bluetooth Always Usage Description and Bluetooth Peripheral Usage Description
  1. Click on the information property list file (default : “Info.plist”).
  2. Add the Privacy – Bluetooth Always Usage Description Key.
  3. If you set Deployment Target to iOS12, add the Privacy – Bluetooth Peripheral Usage Description Key.
  4. Set the reason for using Bluetooth in Value (e.g. Use Bluetooth for communication with the printer.)
  5. When communicating with the Bluetooth printer on iOS 13 or later, an alert requesting permission to access Bluetooth is displayed. The string set in Value is displayed in the alert as the reason for using Bluetooth.

For more information, please refer to the following URL.

https://developer.apple.com/documentation/bundleresources/information_property_list/nsbluetoothperipheralusagedescription

3. Set Local Network Usage Description
  1. Click on the information property list file (default : “Info.plist”).
  2. Add the Privacy - Local Network Usage Description Key.
  3. Set the reason for using Local Network in Value (e.g. Use Local Network for communication with the printer or discovery the printers.)
  4. When communicating with the Ethernet printer on iOS 14 or later, an alert requesting permission to access Local Network is displayed. The string set in Value is displayed in the alert as the reason for using Local Network.

4. Apple Approval Process for STAR MFi Applications

In order to offer your application that communicates a MFi certified printer on the Apple iTunes App Store, your application needs to be approved by the Apple MFi program before you submit it to the Apple iTunes App Store. Please follow the steps described in the URL below to obtain the app approval. This procedure must be completed before the app is reviewed by Apple.

https://star-m.jp/eng/products/s_print/apple_app_mfi.html

⚠️ In case of a Bluetooth Low Energy printer, you do not need to obtain this app approval.

Android

1. Add settings for library dependencies

Add the following configuration to the build.gradle of the app module of the app you wish to embed, which refers to the local Maven repository.

allprojects {
    repositories {
        flatDir {
            dirs "$rootDir/../node_modules/react-native-star-io10/android/src/lib"
        }
    }
}

2. When using a Bluetooth printer

Refer to sample code and request BLUETOOTH_CONNECT permission before starting to communicate with or search for the printer.

3. To prevent the connection permission dialog from being displayed every time the USB cable is plugged in or unplugged

When communicating with a USB printer, a dialog box will appear asking for connection permission. This permission is reset when the USB cable is plugged in or unplugged (including when the printer is turned on or off).

If you do not want to display the connection permission dialog every time the USB cable is plugged in or unplugged, configure the following settings. This setting will also allow the application to start automatically when the USB cable is plugged.

2.1. Add settings to AndroidManifest.xml

Add the following <intent-filter> and <meta-data> elements to AndroidManifest.xml.

<intent-filter>
    <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
    <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
</intent-filter>

<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" android:resource="@xml/device_filter" />
<meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" android:resource="@xml/accessory_filter" />
2.2. Add a resource file

Store the following resource files under res/xml with the names device_filter.xml and accessory_filter.xml.

  • device_filter.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <usb-device class="255" subclass="66" protocol="1" />

    <usb-device vendor-id="1305" product-id="0003" />   <!--TSP100IIU+/IIIU/IV/IV SK-->
    <usb-device vendor-id="1305" product-id="0071" />   <!--mC-Print3-->
    <usb-device vendor-id="1305" product-id="0073" />   <!--mC-Print2-->
    <usb-device vendor-id="1305" product-id="0025" />   <!--mC-Label3-->
    <usb-device vendor-id="1305" product-id="0023" />   <!--mPOP-->
    <usb-device vendor-id="1305" product-id="0001" />   <!--TSP650II/TSP650II SK/TSP700II/TSP800II/SP700/TUP500-->
    <usb-device vendor-id="1305" product-id="0011" />   <!--BSC10-->
    <usb-device vendor-id="1305" product-id="0015" />   <!--TSP043-->
    <usb-device vendor-id="1305" product-id="0017" />   <!--BSC10BR-->
    <usb-device vendor-id="1305" product-id="0075" />   <!--SK1-211/221/V211-->
    <usb-device vendor-id="1305" product-id="0077" />   <!--SK1-311/321/V311-->
    <usb-device vendor-id="1305" product-id="0067" />   <!--SM-S230i-->

</resources>
  • accessory_filter.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <usb-accessory model="Star TSP143IV-UE" manufacturer="STAR"/>
    <usb-accessory model="Star TSP143IV-UE SK" manufacturer="STAR"/>
    <usb-accessory model="mC-Print3" manufacturer="Star Micronics"/>
    <usb-accessory model="mC-Label3" manufacturer="Star Micronics"/>
    <usb-accessory model="mPOP" manufacturer="Star Micronics"/>
</resources>

Windows

  • Add Capability in Package.appxmanifest.
    • Bluetooth
    • Internet (Client)
    • Private Networks (Client & Server)
  • Add "Visual C++ 2015-2019 UWP Desktop Runtime for native apps" to the project "References".

Limitations

When using Android device, an image specified by URL is sometimes printed in a low resolution

In Android, when an image file size is large, and its URL is specified as the source of the ImageParameter which is the argument of the actionPrintImage method, the image may be printed in low resolution.

This can be solved by either of the following methods:

  • Reduce a file size of an image by lowering the resolution beforehand.
  • Download an image in the app and specify the image file directly as the source.

Examples

StarXpand SDK includes an example application that can be used in combination with the printer to check its operation. Please use it in conjunction with the explanations of each function in the linked pages.

The sample code and printed result images are also available here.

  • Sample to create print layouts for receipts and labels for each type of business
  • Sample to generate receipt images from text data (iOS/Android)

⚠️ Some printer models may not be able to print some samples. Please adjust the layout accordingly when using this samples.

Get printer status

async getStatus(): Promise<void> {
    // Specify your printer connection settings.
    var settings = new StarConnectionSettings();
    settings.interfaceType = InterfaceType.Lan;
    settings.identifier = '00:11:62:00:00:00';
    var printer = new StarPrinter(settings);

    try {
        // Connect to the printer.
        await printer.open();

        // Get printer status.
        var status = await printer.getStatus();
        console.log(status);
    }
    catch(error) {
        // Error.
        console.log(error);
    }
    finally {
        // Disconnect from the printer and dispose object.
        await printer.close();
        await printer.dispose();
    }
}

Monitor printer

printer: StarPrinter;

async monitor(): Promise<void> {
    // Specify your printer connection settings.
    var settings = new StarConnectionSettings();
    settings.interfaceType = InterfaceType.Lan;
    settings.identifier = '00:11:62:00:00:00';
    printer = new StarPrinter(settings);

    // Callback for printer state changed.
    printer.printerDelegate.onReady = () => {
        console.log(`Printer: Ready`);
    }
    printer.drawerDelegate.onOpenCloseSignalSwitched = (openCloseSignal) => {
        console.log(`Drawer: Open Close Signal Switched: ${String(openCloseSignal)}`);
    }
    printer.inputDeviceDelegate.onDataReceived = (data) => {
        console.log(`Input Device: DataReceived ${String(data)}`);
    }
    printer.displayDelegate.onConnected = () => {
        console.log(`Display: Connected`);
    }
    // ...
    // Please refer to document for other callback.

    try {
        // Connect to the printer.
        await printer.open();
    }
    catch(error) {
        // Error.
        console.log(error);
    }
}

Copyright

Copyright 2021 Star Micronics Co., Ltd. All rights reserved.

react-native-star-io10's People

Contributors

bandit-ibayashi avatar can-miki avatar gare-bear avatar slauzinho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-star-io10's Issues

Is there a function to align left and right on a single line or column? or how to print like this design?

I am using the mc-print3 model
I want to display the menu on the left and the price on the right

cloudPRNT seems to have a column function.
(https://www.star-m.jp/products/s_print/CloudPRNTSDK/Documentation/en/articles/markup/command_column.html?tabs=tabid-2)

But in the SDK's documentation:
I was only able to find the sort function for an entire line.

I tried using "horizontalTab", but this function could not place the price on the far right.

I have attached a photo of the printed receipt as an example. (Pictures downloaded from the Internet)
As in the attached photo, I would like to know if there is a function that can be printed out right-aligned even if the number of prices increases.

image 8

Multiple opened connections

Hi,

Is it possible to have multiple opened connections to one printer? For example multiple POS-devices getting status updates from the same printer.

Also, is there a way to prevent a printer from being stuck in an "opened" mode?

Thanks

found printer but device not found action print

Found printer: {"_connectionSettings": {"autoSwitchInterface": false, "identifier": "00116206E180", "interfaceType": "Lan"}, "_displayDelegate": {"_onConnected": [Function anonymous], "_onDisconnected": [Function anonymous], "_onEventSet": [Function anonymous], "onCommunicationError": [Function anonymous]}, "_drawerDelegate": {"_onEventSet": [Function anonymous], "_onOpenCloseSignalSwitched": [Function anonymous], "onCommunicationError": [Function anonymous]}, "_eventSubscriptions": [{"remove": [Function remove]}, {"remove": [Function remove]}, {"remove": [Function remove]}, {"remove": [Function remove]}, {"remove": [Function remove]}, {"remove": [Function remove]}, {"remove": [Function remove]}, {"remove": [Function remove]}, {"remove": [Function remove]}, {"remove": [Function remove]}, {"remove": [Function remove]}, {"remove": [Function remove]}, {"remove": [Function remove]}, {"remove": [Function remove]}, {"remove": [Function remove]}, {"remove": [Function remove]}, {"remove": [Function remove]}], "_information": {"_emulation": "StarGraphic", "_model": "Unknown", "_reserved": Map {"multiSession" => true, "responseVersion" => "1.0.1", "dhcp" => true, "usbSerialNumber" => null, "bluetoothAddress" => null, "productSerialNumber" => null, "configSubnetMask" => "0.0.0.0", "macAddress" => "00116206E180", "deviceModel" => "TSP143 (STR_T-001)", "ipAddressProtocol" => "DHCP", "configPrint" => null, "rarp" => null, "deviceCommandSet" => "STAR", "name" => "TSP100LAN", "specifiedIdentifier" => null, "deviceManufacturer" => "Star", "subnetMask" => "255.255.255.0", "hostName" => null, "configGateway" => "0.0.0.0", "nameDetail" => null, "usedIPAddress" => null, "firmwareVersionBoot" => "100", "deviceStatus" => null, "usedPort" => null, "firmwareVersionMain" => "200.110", "configIPAddress" => "0.0.0.0", "ipAddress" => "192.168.1.2", "gateway" => "192.168.1.1", "ipVersion" => 1, "pldRevision" => "", "deviceClass" => "PRINTER"}}, "_inputDeviceDelegate": {"_onConnected": [Function anonymous], "_onDataReceived": [Function anonymous], "_onDisconnected": [Function anonymous], "_onEventSet": [Function anonymous], "onCommunicationError": [Function anonymous]}, "_lock": {"_locked": false, "_sleep": [Function anonymous]}, "_printerDelegate": {"_onCoverClosed": [Function anonymous], "_onCoverOpened": [Function anonymous], "_onError": [Function anonymous], "_onEventSet": [Function anonymous], "_onPaperEmpty": [Function anonymous], "_onPaperNearEmpty": [Function anonymous], "_onPaperReady": [Function anonymous], "_onReady": [Function anonymous], "onCommunicationError": [Function anonymous]}, "getStatusTimeout": 5000, "openTimeout": 10000, "printTimeout": 30000}
LOG Found printer: {"autoSwitchInterface": false, "identifier": "00116206E180", "interfaceType": "Lan"}
LOG Found printer: 00116206E180.
LOG Discovery finished.
LOG Error: StarIO10NotFoundError: Device not found.
LOG Error: StarIO10NotFoundError: Device not found.

Please support. thank so much!

[Android] Cannot build due to "Duplicate class a.a.a.a found in modules"

When building our app for Android using react-native-star-io10, the following error occurred.
This error seems to occur because react-native-star-io10 and other libraries have conflicting obfuscated class names.

> Task :app:checkDebugDuplicateClasses FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class a.a.a.a found in modules jetified-other-runtime (other.aar) and jetified-stario10-runtime (stario10.aar)
     Duplicate class a.a.a.a$a found in modules jetified-other-runtime (other.aar) and jetified-stario10-runtime (stario10.aar)
     Duplicate class a.a.a.a$a$a found in modules jetified-another-runtime (another.aar) and jetified-stario10-runtime (stario10.aar)

To fix this problem, can you change interface names in stario10.aar to globally unique interface names, or hide interfaces obfuscated interfaces like a.a.a.a?
I cannot fix this problem myself because stario10.aar is a closed library.

StarIO10ArgumentError - _errorCode:0

import {
InterfaceType,
StarDeviceDiscoveryManager,
StarDeviceDiscoveryManagerFactory,
} from 'react-native-star-io10'

// const manager = StarDeviceDiscoveryManager
export const discover = async () => {
try {
// Specify your printer interface types.
manager = await StarDeviceDiscoveryManagerFactory.create([
InterfaceType.Bluetooth,
InterfaceType.BluetoothLE,
])

// Set discovery time. (option)
manager.discoveryTime = 10000

// Callback for printer found.
manager.onPrinterFound = (printer) => {
  console.tron.log('======> onPrinterFound', printer)
}

// Callback for discovery finished. (option)
manager.onDiscoveryFinished = () => {
  console.tron.log(`Discovery finished.`)
}

// Start discovery.
await manager.startDiscovery()

// Stop discovery.
// await manager.stopDiscovery()

} catch (error) {
// Error.
console.tron.log('discover on error ', error)
}
}

Invariant: Native Module Cannot be Null (Expo)

Hi there,

I am trying to use this lib for a ios build and when debugging in metro I get the "Native Module Cannot be Null" error (please see screenshot attached). It goes away when I comment the printing code so it is definitely coming from this, I have installed npm package and have listed the package "react-native-star-io10" in my package.json as well but no luck.

I have been trying to solve this for a while, would greatly appreciate any help :)

image

[Android] Issue when generating apk file with command line tools

I waned apk file.
But, the process is stacked when assembling, though I can run app when doing npx react-native run-android.

Here is what I tried.

1.npx react-native run-android
→Complete. The app is available on the android and can print on the printer.

2.I wanted apk file. So, I tried this.
react-native bundle --dev false --platform android --entry-file index.js --bundle-output ./android/app/build/generated/assets/react/debug/index.android.bundle --assets-dest ./android/app/build/res/react/debug

./gradlew assembleDebug

→Error occured.

Task :react-native-star-io10:bundleDebugAar FAILED
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-star-io10:bundleDebugAar'.

Error while evaluating property 'hasLocalAarDeps' of task ':react-native-star-io10:bundleDebugAar'
Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error). The following direct local .aar file dependencies of the :react-native-star-io10 project caused this error: C:\XXXXXXXXXXXXXX\PrintApp\node_modules\react-native-star-io10\android\src\lib\stario10.aar

3.Then,i read this article. And ,do this.
・Create a new directory(aar_module) and put the following content into the build.gradle file withing the new directory:

configurations.maybeCreate("default")
artifacts.add("default", file('stario10.aar'))

・Place the stario10.aar into this new directoy.(aar_module) Next to the build.gradle file.
・Add the new created Gradle project to the settings.gradle file:
include(':aar-module')
・Include the project in the node_modules\react-native-star-io10\android\build.gradle

- implementation files('src/lib/stario10.aar')
+ implementation(project(":aar-module"))

./gradlew assembleDebug
→Error occured.(also doing npx react-native run-android)

No matching configuration of project :aar-module was found. The consumer was configured to find a runtime of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug' but:
- None of the consumable configurations have attributes.

Problem with installing

I created a new project (expo bare workflow) and installed react-native-star-io10, after I created a screen based on this example
And when I click on "Discovery" button, I was faced with the next error:

Error: TypeError: null is not an object (evaluating '_reactNative.NativeModules.StarDeviceDiscoveryManagerWrapper.init')

Also, I tried to start an example from this repo, but was faced with the same error.
I tested only on Android

Any idea what I'm doing wrong?

setting paper upside down

When I set paper upside down , the empty receipt is outputted.
But, the program sees it as success and goes on to the 'then' process not 'catch'.
Is there some solutions to find error when I set paper upside down?
My printer is MCP31.

紙を上下逆(下から上に紙が来ている状態)でセットすると、真っ白な紙がパーシャルカットのみされて出力されます。
このとき、プログラム上は、印刷が成功したとみなしているようで、後続の処理を行ってしまいます。
これを防ぐために、紙の向きが逆の状態を判別する、もしくは、紙の向きが逆のときにエラーを表示する
などをすることはできないでしょうか?

Centering the QR code

Is there any way to center the QR code? My print command looks like this:

printerBuilder.actionPrintQRCode(
						new StarXpandCommand.Printer.QRCodeParameter("https://google.com")
                                                          .setModel(
								StarXpandCommand.Printer.QRCodeModel.Model2
							)
							.setLevel(StarXpandCommand.Printer.QRCodeLevel.M)
							.setCellSize(8)
					)

Problem designing the receipt [TSP100IIIU]

We are having major problems with printing and cannot create spaces and having problems with designing the receipt. Can anybody help please? We purchased printer but cannot progress due to what seems is the SDK having bugs.

Compile errors

Hello,

I am getting compiler errors when building my project with following compiler options and TS v3.9.9:

"compilerOptions": {
    "lib": ["es2020", "dom"],
    "module": "es2020",
    "target": "es2018",
    "jsx": "react-native",
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "strict": true,
    "noImplicitAny": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "allowJs": true,
    "checkJs": true,
    "preserveConstEnums": true
  }

here is the output i am getting:

$ tsc -p tsconfig.json --noEmit
Error: node_modules/react-native-star-io10/src/StarDeviceDiscoveryManager.ts(82,71): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarDeviceDiscoveryManager.ts(94,71): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarDeviceDiscoveryManagerFactory.ts(12,71): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarIO10Logger.ts(30,71): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarIO10Logger.ts(40,71): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarIO10Logger.ts(51,46): error TS6133: 'nativeObject' is declared but its value is never read.
Error: node_modules/react-native-star-io10/src/StarPrinter.ts(242,71): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarPrinter.ts(257,71): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarPrinter.ts(267,71): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarPrinter.ts(277,71): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarPrinter.ts(289,71): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DisplayBuilder.ts(11,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DisplayBuilder.ts(23,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DisplayBuilder.ts(35,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DisplayBuilder.ts(47,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DisplayBuilder.ts(59,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DisplayBuilder.ts(71,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DisplayBuilder.ts(83,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DisplayBuilder.ts(95,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DisplayBuilder.ts(107,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DisplayBuilder.ts(119,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DocumentBuilder.ts(11,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DocumentBuilder.ts(23,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DocumentBuilder.ts(35,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DocumentBuilder.ts(47,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DocumentBuilder.ts(59,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DocumentBuilder.ts(73,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DocumentBuilder.ts(87,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DocumentBuilder.ts(101,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DocumentBuilder.ts(115,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DocumentBuilder.ts(129,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DocumentBuilder.ts(141,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DrawerBuilder.ts(11,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/MelodySpeakerBuilder.ts(11,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/MelodySpeakerBuilder.ts(23,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(11,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(23,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(35,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(47,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(59,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(71,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(83,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(95,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(107,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(119,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(131,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(143,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(155,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(167,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(179,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(191,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(203,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(215,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(227,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(239,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(251,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(265,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PreSettingBuilder.ts(13,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PreSettingBuilder.ts(27,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PresenterSettingBuilder.ts(11,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PresenterSettingBuilder.ts(23,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(11,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(25,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(37,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(49,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(61,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(73,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(85,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(97,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(109,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(121,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(133,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(145,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(157,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(169,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(181,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(193,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(205,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(217,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(229,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(241,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(253,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(265,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(277,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(289,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(303,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/StarXpandCommandBuilder.ts(32,79): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/StarXpandCommandBuilder.ts(45,75): error TS2339: Property 'code' does not exist on type 'Error'.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 1.

By the looks of it the type Error was meant to be overriden somewhere but instead the basic Error type is used and it of course fails as there is not code param on it. Also there is no typescript in package.json dependancies so it is hard to tell wether it may be some TS mismatch.

Cannot discovery in Android

In iOS I found 2 printers (TSP650II and mC_Print3) by Lan. But in Android, I could not find any devices.
Here is my problem:

try {
      let manager = await StarDeviceDiscoveryManagerFactory.create(interfaceType);

      manager.discoveryTime = 10000;

      let newPrinters = [];

      manager.onPrinterFound = (printer) => {
        // iOS working well but Android does not
        newPrinters.push(printer);
        newPrinters = newPrinters.filter(
          (thing, index, self) =>
            index ===
            self.findIndex(
              (t) => t?.connectionSettings?.identifier === thing?.connectionSettings?.identifier,
            ),
        );
        setState({ ...state, printers: newPrinters });
        setStartFind(false);
      };

      manager.onDiscoveryFinished = () => {
        setStartFind(false);
      };

      await manager.startDiscovery();
    } catch (error) {
      setStartFind(false);
      alert(error);
    }

Any solution for this problem. Thank you!

EXC_BAD_ACCESS causing application crash

Hello,

We're starting to see hard crashes in our application that appear to be originating from the StarLogger, resulting in random crashes in our application. Any insight would be great. Here is information from our Sentry integration:

image

Is it possible to disable StarIO10's logger entirely to avoid this issue?

Failed to create image decoder with message 'unimplemented'

Getting an error when trying to print and image, this is on the mCPrint3 printer. I'm passing in a valid http url but it seems to throw this error:

07-22 14:44:37.272  8746  8790 D skia    : --- Failed to create image decoder with message 'unimplemented'
07-22 14:44:37.272  8746  8790 D DRM/DcfDecoder: decodeDrmImageIfNeeded with data

I'm on Android running it in production mode. Any idea if there's a work around? Worst case scenario I feel like a failed image shouldn't cancel all the print actions (which is what's happening now).

[iOS] StarIO10/PrinterPortFactory.swift:37: Fatal error

While testing with a SM-L300 printer on iOS, the following error was found after a printing request

StarPrinter class

image

StarDeviceDiscoveryManager.onPrinterFound() only retrieves the identifier and interface type of the printer. I am not sure why the value of emulation and model is Unknown. That might be relevant to the error?

Device information

  • Printer: SM-L300
  • Device: iPad Pro (11-inch) (v15.1)
  • Xcode: Version 13.1 (13A1030d)
  • macOS: Big Sur v11.4

Replication Steps

  • run await printer.print(commands); with SM-L300 printer

Info.plist

...
  <key>NSBluetoothAlwaysUsageDescription</key>
	<string>For connecting to print and barcode scanning</string>
  <key>NSBluetoothPeripheralUsageDescription</key>
	<string>For connecting to printers and barcode scanners</string>
  <key>NSLocalNetworkUsageDescription</key>
	<string>For connecting to print local network</string>
  <key>UISupportedExternalAccessoryProtocols</key>
	<array>
		<string>jp.star-m.starpro</string>
	</array>
...

Logs

2021-12-10 00:54:07.349979-0800 TestStarReceipt[599:107012] IAPAppRegisterClient: capabilities 0x8020
2021-12-10 00:54:07.350084-0800 TestStarReceipt[599:107012] IAPAppRegisterClient: __eaClientRegisterediapd 0 -> 1
2021-12-10 00:54:07.350118-0800 TestStarReceipt[599:107012] IAPAppRegisterClient: __eaClientRegisterediap2d 0 -> 1
2021-12-10 00:54:07.350330-0800 TestStarReceipt[599:107012] IAPDHasLaunched: kIAPAvailableNotification iapdAvailableState 100 -> 0
2021-12-10 00:54:07.350392-0800 TestStarReceipt[599:107012] IAPAppRegisterClient: __eaiapdHasClientID 0, IAPDHasLaunched 0
2021-12-10 00:54:07.350752-0800 TestStarReceipt[599:107012] IAP2DHasLaunched: kIAP2AvailableNotification iap2dAvailableState 100 -> 0
2021-12-10 00:54:07.350820-0800 TestStarReceipt[599:107012] IAPAppRegisterClient: __eaiap2dHasClientID 0, IAP2DHasLaunched 0
2021-12-10 00:54:07.351011-0800 TestStarReceipt[599:107012] IAPAppRegisterClient: registerWasSuccessful 0
2021-12-10 00:54:07.351469-0800 TestStarReceipt[599:107012] -[EAAccessoryManager _initFromSingletonCreationMethod] isRunningOnMac
2021-12-10 00:54:07.353445-0800 TestStarReceipt[599:107012] IAPAppConnectedAccessories: __eaClientHasCheckedForConnectedAccessories 0 -> 1
2021-12-10 00:54:07.353701-0800 TestStarReceipt[599:107012] IAPAppConnectedAccessories: IAPDHasLaunched 0, IAP2DHasLaunched 0
StarIO10/PrinterPortFactory.swift:37: Fatal error
2021-12-10 00:54:22.301739-0800 TestStarReceipt[599:107092] StarIO10/PrinterPortFactory.swift:37: Fatal error
(lldb) 

Request timed out - IOS only

Thanks for putting this library together. It is working great for us on Android but we're having problems on IOS.

Discovery is fine although the identifier looks quite different on IOS (16 numeric digits) whereas Android has 12 alpha-numeric digits.

When trying to open the printer to either get status or print we get StarIO10CommunicationsError: Request timed out. This is when running the app from XCode with the iPhone connected via USB. I also tried running the Example apps from this project and get the same results - discovery is okay but get status and printing fails.

It looks like it is communicating at some level as, before the timeout, the bluetooth signal icon on the printer flashes multiple times.

I downloaded the mPop utility and it can discover and successfully print a sample label ...although if I try to get status or access settings it pauses for a few seconds and comes up with the message "Failure".

These are the devices involved:

Printer - Star SM-T300i firmware version 4.0 in StarPRNT mode with "Bluetooth-Auto" showing on the display.
iPhone 7 running IOS 14.6

Any help is greatly appreciated.

Detection of cash drawer

Is there any possibility to detect, whether cashDrawer is connected to a printer?
Is it possible to detect key-locking of a drawer?

Fresco 2.5.0

Hello,

We are using Fresco 2.5.0 in our react native android app, and it seems to conflict with the code in your library and cause build errors regarding the following:

  • BaseBitmapDataSubscriber.onFailureImpl() signature has changed (param should not be nullable anymore)

override fun onFailureImpl(dataSource: DataSource<CloseableReference<CloseableImage>>?) {

  • A newer version of OkHttpClient is used, so the body() method of the Response object is deprecated and was replace with the "body" property

response.body()?.bytes()?.let { responseBytes ->

Are you planing on supporting the newer versions of Fresco so the lib can be used in projects that use them?

Thanks!

Column support

Does the SDK support columns whereby I can print a barcode followed by a price for example. If so, example code would be appreciated

Text wrap

How do I control printing descriptions that exceed the label width? Do you support wrapping or other methods?

Android: Execution failed for task ':react-native-star-io10:bundleReleaseAar'

  • What went wrong:
    Execution failed for task ':react-native-star-io10:bundleReleaseAar'.

Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error). The following direct local .aar file dependencies of the :react-native-star-io10 project caused this error: /node_modules/react-native-star-io10/android/src/lib/stario10.aar

When trying to build the project on android with latest react native.

Receipt content is blurry on SP700

Hi, one of our clients reported to us that their receipt content is blurry. It only occurs to our app since their printer works fine on Clover system.
image

Incomplete documentation - MFi requirements

The README for this project and the associated linked documentation does not make mention of the need to register to receive the MFi Product Plan ID that's required to be submitted with the Apple release process.

Can the README file be updated to reflect this requirement along with the link to register please? Not being aware of this requirement from the beginning has now resulted in our app release being delayed and having the requirement listed here will help others in the future.

https://www.star-m.jp/eng/contact/su03/inquiry03-4.html

[Android] `StarPrinterInformation` object returns `emulation: unknown` to all BT printers

Hi,

There is an issue of StarPrinterInformation object returns emulation: unknown to all BT printers on Android

Using StarDeviceDiscoveryManager.startDiscovery()
and StarDeviceDiscoveryManager.onPrinterFound: (printer: StarPrinter) => void,
StarPrinter.information is not working as expected

To enable, print() method, emulation property should be stored and returned, but it doesn't show up for all Star Bluetooth printers.

I've checked LAN/WiFi printers, they work fine.

Is there a workaround to get the emulation value?

image

Scanning bluetooth with IOS

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)}`);
}

`

Android build fails

Error in Android: cannot access 'body': it is package-private in 'response'

Please help

MC-Print3 takes about 15 seconds to print

There is about a 15 second delay after sending the print command. Is there any way to fix this? Here is my code

  const printOrder = async ({
    id,
    price,
    items,
    dispensary,
    pickup_time_end,
    payment_method,
    pickup_time_start,
    created_at,
    user,
    guest_user,
  }: OrderTicketFragment) => {
    if (!printer) {
      toast.show({
        title: 'No Printer connected',
      });
      return;
    }
    setPrinting(true);
    toast.show({
      title: 'Printing',
    });
    const builder = new StarXpandCommand.StarXpandCommandBuilder();
    const customer = user ?? guest_user;
    const columns = 48;
    const hr = `${'-'.repeat(columns)}\n`;
    const subtotal = items.reduce(
      (acc, item) => acc + item.price * item.quantity,
      0
    );
    const tax = (value: number): string => money(subtotal * (value / 100));

    const [salesTax, cannabisTax, localTax] = [
      dispensary.sales_tax,
      dispensary.marijuana_tax,
      dispensary.local_tax,
    ].map(tax);

    const subtotalText = `SUBTOTAL${' '.repeat(
      3 - (cannabisTax.length - money(subtotal).length)
    )}${money(subtotal)}`;
    const paymentText = `Payment ${
      payment_method === Payment_Methods_Enum.Card ? 'Card' : 'Cash'
    }`;

    builder.addDocument(
      new StarXpandCommand.DocumentBuilder().addPrinter(
        new StarXpandCommand.PrinterBuilder()
          .styleInternationalCharacter(
            StarXpandCommand.Printer.InternationalCharacterType.Usa
          )
          .styleAlignment(StarXpandCommand.Printer.Alignment.Center)
          .styleMagnification(new StarXpandCommand.MagnificationParameter(4, 4))
          .actionPrintText('YouGotBud\n')
          .styleMagnification(new StarXpandCommand.MagnificationParameter(2, 2))
          .actionPrintText(
            [pickup_time_start, pickup_time_end].map(formatTime).join('-') +
              '\n'
          )
          .actionPrintText(fullName(customer!).toUpperCase() + '\n')
          .styleMagnification(new StarXpandCommand.MagnificationParameter(1, 1))
          .actionPrintText(
            lines(
              ...([
                `Order #: ${id}`,
                customer?.phone_number
                  ? `Phone: ${customer?.phone_number}`
                  : null,
                customer?.email ? `Email: ${customer?.email}` : null,
              ].filter(value => value !== null) as string[])
            )
          )
          .styleAlignment(StarXpandCommand.Printer.Alignment.Left)
          .actionPrintText(hr)
          .actionPrintText(
            lines(
              ...items.map(({quantity, price, product_variant, product}) => {
                const pad = ' '.repeat(quantity.toString().length + 2);
                const productSection =
                  `${quantity}  ${product.brand!.name}${' '.repeat(
                    columns -
                      2 -
                      quantity.toString().length -
                      product.brand!.name.length -
                      money(price).length
                  )}${money(price * quantity)}` +
                  `${pad}${
                    product.name.split(' ').reduce(
                      (acc, word) => ({
                        length: acc.length + word.length,
                        value:
                          acc.value +
                          (acc.length % 8 === 0
                            ? acc.length === 0
                              ? word
                              : `\n${pad}${word}`
                            : ` ${word}`),
                      }),
                      {length: 0, value: ''}
                    ).value
                  }\n` +
                  (!!product_variant
                    ? `${pad}${product_variant!.name}\n\n`
                    : '\n');

                return productSection;
              })
            )
          )
          .actionPrintText(hr)
          .actionPrintText(
            `${paymentText}${' '.repeat(
              columns - paymentText.length - subtotalText.length
            )}${subtotalText}\n`
          )
          .styleAlignment(StarXpandCommand.Printer.Alignment.Right)
          .actionPrintText(
            `LOCAL TAX${' '.repeat(
              4 - (cannabisTax.length - localTax.length)
            )}${localTax}\n`
          )
          .actionPrintText(
            `SALES TAX${' '.repeat(
              4 - (cannabisTax.length - salesTax.length)
            )}${salesTax}\n`
          )
          .actionPrintText(`CANNABIS TAX ${cannabisTax}\n`)
          .styleAlignment(StarXpandCommand.Printer.Alignment.Left)
          .actionPrintText(hr)
          .styleMagnification(new StarXpandCommand.MagnificationParameter(2, 2))
          .styleAlignment(StarXpandCommand.Printer.Alignment.Right)
          .actionPrintText(`Order Total ${money(price)}`)
          .styleMagnification(new StarXpandCommand.MagnificationParameter(1, 1))
          .styleAlignment(StarXpandCommand.Printer.Alignment.Left)
          .actionPrintText(hr)
          .styleAlignment(StarXpandCommand.Printer.Alignment.Center)
          .actionPrintText(
            `Ordered: ${dayjs(created_at).format('MM/DD/YY - HH:mm a')} \n\n`
          )
          .actionPrintText(`Thank you for shopping at ${dispensary.name}`)
          .actionCut(StarXpandCommand.Printer.CutType.Full)
      )
    );
    await printer.print(await builder.getCommands());
    setPrinting(false);
  };

Example project does not work with XCode 12.5.1

DistributedMutex-inl.h:1051:5: 'atomic_notify_one<unsigned long>' is unavailable


node_modules/react-native-star-io10/example/ios/Pods/Headers/Private/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h:1051:5: 'atomic_notify_one<unsigned long>' is unavailable

This is completely fresh and untouched. I just started the example project and tried to make a release build.

Example in JavaScript

We already have a project in react native written on javascript, and the example of printing is on Typescript ..

can you share the javascript example also that will be very helpful

Avoid breaking words and "advanced" aligning options

Is there a way to stop the library from breaking a word? Right now it prints something like:

Hello I am a test wh
ich should not break

I'm trying to print a table of payment breakdown, so are there options to:

  1. Create a horizontal line across? I mean something like -------------------- but not a collection of dashes and from the left to the right
  2. Is there a way, on a single line, to align some text to the left and other text to the right, so it prints something like this, but imagine it is stretches from the left to the right
-------------------------------------------
Price                                $90.00

Generate and print image in react-native

I'm using this library in a react-native app to print text with my thermal printer (bluetooth). However, when I print, it always prints a short black paper and cuts. I know the problem is not with the printer, because I printed a self test (holding power + feed button) and it worked. There's also no error in the console when printing.

Here are my printer details:
Model: TSP100IIIBI
Firmware: 2.0
Version of react-native-star-io10: 1.0.0

Here is the part of my code that prints:

function print() {
        const printerSettings = new StarConnectionSettings();
        printerSettings.interfaceType = this.state.settings.interfaceType;
        printerSettings.identifier = this.state.settings.identifier;
        const printer = new StarPrinter(printerSettings);

        try {
            await printer.open();
            const builder = new StarXpandCommand.StarXpandCommandBuilder();
            builder.addDocument(
                new StarXpandCommand.DocumentBuilder().addPrinter(
                    new StarXpandCommand.PrinterBuilder()
                        .styleInternationalCharacter(
                            StarXpandCommand.Printer.InternationalCharacterType.Usa,
                        )
                        .styleCharacterSpace(0)
                        .styleAlignment(StarXpandCommand.Printer.Alignment.Center)
                        .styleBold(true)
                        .actionPrintText('Test\n')
                        .actionCut(StarXpandCommand.Printer.CutType.Partial),
                ),
            );
            const commands = await builder.getCommands();

            await printer.print(commands);
        } catch (error) {
            if (error instanceof StarIO10Error) {
                Alert.alert('Could not print', error.message);
            }
        } finally {
            await printer.close();
            await printer.dispose();
        }
    }

How to align printed image?

Hi, I'm trying to print an image on our receipt and it works well once I realized that the image can't be an SVG (should probably add to the docs). The only thing that I'm having trouble with now is placement of the image. How do I go about doing this? I'm using the actionPrintImage command. Thanks in advance.

プリンターにBluetooth接続できない

ご確認お願いします 🙇‍♂️

manager.discoveryTime

Could you please explain why this delay is necessary? Are some devices of specific interfaces not picked up right away?

Android: The printer model of the discovered Bluetooth-connected printer is Unknown.

The printer model of the discovered Bluetooth-connected printer is Unknown on Android.
I can get the correct printer model on iOS.

Android iOS
android ios

Reference code

const starDeviceDiscoveryManager =
    await StarDeviceDiscoveryManagerFactory.create([
    InterfaceType.Lan,
    InterfaceType.Usb,
    ...(!isEmulator ? [InterfaceType.Bluetooth] : []),
    ...(!isEmulator && Platform.OS === 'ios'
        ? [InterfaceType.BluetoothLE]
        : []),
    ]);
starDeviceDiscoveryManager.onPrinterFound = (printer: StarPrinter) => {
    // printer.information.model is Uknown on Android.
};
await starDeviceDiscoveryManager.startDiscovery();

Reference my app

https://github.com/yhirano/ReactNativeUseStarPrinterSampleApp

StarIO10CommunicationError: Open failed.

StarIO10CommunicationError: Open failed.

I get printer instance from discovery function, and use that instance to open connection. But it fails, can anybody help ?

Intermittent Printer open fails with error code: 0

Failure is happening when we call open on the printer:

let printer = new StarPrinter(printerConfig.connectionSettings);
await printer.open();

The exception we get is below:

"error":"{\n  \"name\": \"v\"\n}",

"error":{"_errorCode":0,"name":"v","line":63,"column":331,"sourceURL":"index.android.bundle"

Initially Printer open and print works fine for some time and then it starts failing continuously with this error. If we reinstall it gets fixed.

Release Build failed at bundleReleaseAar

I tried to compile a release build on Android for testing and received this error:

Task :react-native-star-io10:bundleReleaseAar FAILED
w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-star-io10:bundleReleaseAar'.
> Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error). The following direct local .aar file dependencies of the :react-native-star-io10 project caused this error: /[REDACTED]/node_modules/react-native-star-io10/android/src/lib/stario10.aar

Here's the command I used to build:

cd ./android && ./gradlew assembleRelease && cd ..

Not sure where to go from here, do I need to include the aar files in gradle somehow?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.