API: Scan Using HID Scanner Connected via Star Micronics Printer Hub
Scan barcodes & QR codes through a scanner connected through a Star Micronics printer.
In this article
Requirements
- Integration of our JavaScript API into your webpage
- Sample code to run within the app and download for integration into your own project is available here.
- Best practices for working with the JavaScript API are available here.
- App Settings
- Content > JavaScript API > Access JavaScript API = By Import
- Printing
- Enable Star Micronics Printer = On
- Star Micronics Printer Settings > Select Printer = select your printer or enter Port Name:
- if connecting via Wi-Fi = 'TCP:' + the IP address of the printer
- if connecting via Bluetooth = 'BT:' + name assigned to printer
- Star Micronics Printer Settings > Port Settings = 9100, unless specifically changed during printer set-up
- Physical Hardware
- Star Micronics thermal kiosk printer with a hub - this includes mC-Print series printers (except MCP20 and MCP30 models) and all models of the mPop.
- connected compatible scanner. For testing, we used Star's 1D mPOP handheld barcode scanner with stand (part number 39594110). Per Star's support team, if you have updated the printer's firmware to version 3.0 or later, the SDK should work with any HID scanner that can be connected via USB-A.
- iOS/iPadOS Permissions
- Bluetooth (if using a Bluetooth-connected printer) - more on enabling specific iOS/iPadOS permissions here
Triggers via API Functions
Start Listening for Scanning
This function starts listening for scan events.
Format | kp_StarPrinter_startListenToBarcodeScannerEvents(); |
Status
Kiosk Pro will trigger one or more of the following callbacks depending on the status of the operation:
- kp_StarPrinter_barcodeScannerDidReceiveData - the scan was successful
- kp_StarPrinter_didStartListenToBarcodeScannerEvents - the scan request has started
- kp_StarPrinter_barcodeScannerConnected - the barcode scanner is connected
- kp_StarPrinter_barcodeScannerDisconnected - the barcode scanner is not connected
- kp_StarPrinter_barcodeScannerNotSupported - the printer does not support barcode scanning
Stop Listening for Scanning
This function stops listening for scanning events.
Format | kp_StarPrinter_stopListenToBarcodeScannerEvents(); |
Status
Kiosk Pro will trigger the following callback:
- kp_StarPrinter_didStopListenToBarcodeScannerEvents - the scan request has ended
Notifications via API Callbacks
When Barcode is Scanned
This callback is triggered when a barcode scan is successful and returns the result.
Format | kp_StarPrinter_barcodeScannerDidReceiveData(data); |
Return values | data - [string] the data from barcode |
When Scanner is Connected
This callback is triggered when the barcode scanner is connected or after kp_StarPrinter_startListenToBarcodeScannerEvents is called while the scanner is connected.
Format | kp_StarPrinter_barcodeScannerConnected(); |
When Scanner is Disconnected
This callback is triggered when the barcode scanner is disconnected or after kp_StarPrinter_startListenToBarcodeScannerEvents is called while the scanner is disconnected.
Format | kp_StarPrinter_barcodeScannerDisconnected(); |
When the Connected Printer Does Not Support Scanning
This callback is triggered when the Star printer currently connected does not support barcode scanning.
Format | kp_StarPrinter_barcodeScannerNotSupported(); |
When Listening Starts
This callback is triggered when the app starts listening for scanning events.
Format | kp_StarPrinter_didStartListenToBarcodeScannerEvents(); |
When the Connected Printer Does Not Support Scanning
This callback is triggered when the app stops listening for scanning events.
Format | kp_StarPrinter_didStopListenToBarcodeScannerEvents(); |
Sample Code
- This sample code relies on the JavaScript APIs built into Kiosk Pro and will not run successfully in other browsers or within our in-app help interface.
- To run sample code, set the app's homepage to kioskgroup.com/star-micronics-barcode-scanner-api
- To download a .zip of sample code, click here.
Change Log
- Added in version 9.2