-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
104 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,46 @@ | ||
# React Native Honeywell Scanner | ||
# React Native Honeywell Printer | ||
|
||
This package works with Honeywell devices that have an integrated barcode scanner, like the Honeywell Dolphin CT50. This package was fully tested with a CT50, since the SDK is not specific to the CT50 other devices will likely work as well but this is not guaranteed. | ||
This package works with Honeywell devices that use the Intermec PB50 printer. It may also work on other Intermec printers, but this is not guaranteed. | ||
|
||
TODO: | ||
Note that this is an experimental package. | ||
|
||
- Find out how printerprofiles.json works | ||
- Properly rotate text on PB50 printer | ||
- Make sure printer is stable | ||
- Cleanup printerprofiles | ||
- Write documentation | ||
Tested to work with React Native 0.56 and 0.57. Only works on Android. | ||
|
||
## Installation | ||
|
||
``` | ||
yarn add react-native-honeywell-scanner | ||
yarn add react-native-honeywell-printer | ||
``` | ||
|
||
To install the native dependencies: | ||
|
||
``` | ||
react-native link react-native-honeywell-scanner | ||
react-native link react-native-honeywell-printer | ||
``` | ||
|
||
## Usage | ||
|
||
First you'll want to check whether the device is a Honeywell scanner: | ||
First you need to copy `printerprofiles.json` from this repository to `android/app/src/main/assets/printerprofiles.json` in your project. You can modify this file to change the styling of the print document. | ||
|
||
```js | ||
import HoneywellPrinter from 'react-native-honeywell-scanner'; | ||
import honeywellPrinter from 'react-native-honeywell-printer'; | ||
|
||
HoneywellPrinter.isCompatible // true or false | ||
async function print() { | ||
const devices = await BluetoothSerial.list(); | ||
// Search for Intermec PB50 devices; this is the only tested printer at the moment. | ||
const device = devices.find(device => device.name.includes('PB50')); | ||
if (device) { | ||
// This is the profile name defined in android/app/src/main/assets/printerprofiles.json | ||
const profileName = 'PB32_Fingerprint'; | ||
await honeywellPrinter.print(profileName, device.id, 'My variable to print'); | ||
} | ||
} | ||
``` | ||
|
||
The barcode reader needs to be "claimed" by your application; meanwhile no other application can use it. You can do that like this: | ||
|
||
```js | ||
HoneywellPrinter.startReader().then((claimed) => { | ||
console.log(claimed ? 'Barcode reader is claimed' : 'Barcode reader is busy'); | ||
}); | ||
``` | ||
|
||
To free the claim and stop the reader, also freeing up resources: | ||
|
||
```js | ||
HoneywellPrinter.stopReader().then(() => { | ||
console.log('Freedom!'); | ||
}); | ||
``` | ||
|
||
To get events from the barcode scanner: | ||
|
||
```js | ||
HoneywellPrinter.on('barcodeReadSuccess', event => { | ||
console.log('Received data', event); | ||
}); | ||
|
||
HoneywellPrinter.on('barcodeReadFail', () => { | ||
console.log('Barcode read failed'); | ||
}); | ||
``` | ||
|
||
To stop receiving events: | ||
|
||
```js | ||
function barcodeReadFail = () => console.log('Barcode read failed'); | ||
HoneywellPrinter.off('barcodeReadFail', handler); | ||
``` | ||
|
||
## TODO | ||
|
||
## Inspiration | ||
- There is no progress indication | ||
- There is no indication whether printing succeeded or failed | ||
|
||
The [react-native-bluetooth-serial](https://github.com/rusel1989/react-native-bluetooth-serial) project was used as inspiration. [cordova-honeywell](https://github.com/icsfl/cordova-honeywell) also served as some inspiration. | ||
We probably won't have time to build this since we'll only have a Intermec printer for a limited time. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
{ | ||
"name": "react-native-honeywell-printer", | ||
"description": "A barcode scanner for Honeywell handheld devices like Honeywell Dolphin CT50", | ||
"description": "Print barcodes and text with a Honeywell Intermec printer with React Native", | ||
"version": "1.0.1", | ||
"main": "index.js", | ||
"author": "Kees Kluskens <[email protected]>", | ||
"repository": "Volst/react-native-honeywell-printer", | ||
"keywords": [ | ||
"honeywell", | ||
"barcode", | ||
"scanner" | ||
"intermec", | ||
"pb50", | ||
"printer" | ||
], | ||
"engines": { | ||
"node": ">=4.0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{ | ||
"LINEPRINTERCONTROL": | ||
{ | ||
"FormatVersion": "1.0.0.0", | ||
"Platform": "Android", | ||
"DEFAULTS": | ||
{ | ||
"BoldIsFont": true, "BoldOff": "[0x1b,0x77,!]", "BoldOn": "[0x1b,0x77,0x6D]", | ||
"CompressDotsHigh": 12, "CompressIsFont": true, "CompressOff": "[0x1b,0x77,!]", | ||
"CompressOn": "[0x1b,0x77,0x42]", "DoubleHighDotsHigh": 32, "DoubleHighIsFont": false, | ||
"DoubleHighMask": 16, "DoubleHighOff": "[0x1b,!,0x10]", "DoubleHighOn": "[0x1b,!,0x10]", | ||
"DoubleWideDotsHigh": 16, "DoubleWideHighPrefix": "[0x1b,!]", "DoubleWideIsFont": false, | ||
"DoubleWideMask": 32, "DoubleWideOff": "[0x1b,!,0x20]", "DoubleWideOn": "[0x1b,!,0x20]", | ||
"Initialize": "[0x00,0x00,0x00,0x00,0x1b,0x40,0x00,0x00,0x00]", | ||
"NormalFont": "[0x1b,0x77,!,0x1b,!,0x00]", "NewLine": "[0x0d]", "NormalDotsHigh": 16, | ||
"FormFeed": "[0x0d,0x0d,0x0d,0x0d,0x0d]", "ValidateAttribOnFormFeed": true, | ||
"PrintHeadWidth": 384, "UseDoubleHWMask": true, "ValidateAttribOnFont": true, | ||
"ValidateAttribOnNewLn": true, "NullsBeforeClose": 0, "PreCloseDelay": 0, "EndOfGraphicsDelay": 0, | ||
"PostGraphicsDelay": 0, "PostGraphicsLineDelay": 0, "PreGraphicsDelay": 0, "StartOfGraphicsDelay": 0, | ||
"BtConnectRetries" : 3, "BtconnectRetryDelay" : 100, "BtWriteDataReadyTimeout" : 10000, "BtWriteIntervalTimeout" : 10000, | ||
"BtMaxSegWrite" : 1024, "BtMaxSegRead" : 1024, "BtLinger" : 10 | ||
}, | ||
|
||
"PRINTERS": | ||
{ | ||
"PB32_Fingerprint": | ||
{ | ||
"DisplayName":"PB32 Bt Label Printer", "PrintHeadWidth": 576, "LABEL_01": "3in_FingerprintLabels", | ||
"FormFeed": "[0x46,0x4F,0x52,0x4D,0x46,0x45,0x45,0x44]", | ||
"Initialize": [], "NormalFont": [], "NullsBeforeClose": 0, "PreCloseDelay": 1000 | ||
} | ||
}, | ||
|
||
"LABELS": | ||
{ | ||
"3in_FingerprintLabels": | ||
{ | ||
"ItemLabel": | ||
{ | ||
"LabelDataStream": "PRPOS 200,0:DIR 1:AN 5:PP 180, 180:FT \"Swiss 721 Bold Condensed BT\",20:PT \"TextMsg$$\":PF\r\n", | ||
"VarPostfix": "$$" | ||
} | ||
} | ||
}, | ||
"STATUS": | ||
{ | ||
"ESCP_StatusQueries" : | ||
{ | ||
"QUERIES" : | ||
[ | ||
{ | ||
"GetStatusCommand" : "[0x1b,{,S,T,?,}]", | ||
"StatusInitTimeout" : 5000, | ||
"StatusGapTimeout" : 500, | ||
"StatusEndResponse" : "[}]", | ||
"RESPONSES" : | ||
[ | ||
{ "PrinterMsg" : "[P,:,N]", "MsgNo" : 223 }, | ||
{ "PrinterMsg" : "[B,:,V]", "MsgNo" : 226 }, | ||
{ "PrinterMsg" : "[L,:,U]", "MsgNo" : 227 }, | ||
{ "PrinterMsg" : "[H,:,T]", "MsgNo" : 228 }, | ||
{ "PrinterMsg" : "[E,:,c]", "MsgNo" : 1001 }, | ||
{ "PrinterMsg" : "[E,:,d]", "MsgNo" : 1002 }, | ||
{ "PrinterMsg" : "[E,:,f]", "MsgNo" : 1003 }, | ||
{ "PrinterMsg" : "[E,:,g]", "MsgNo" : 1004 } | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
|