Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AA] Making dev branch compile and passing paperLabelName parameter #35

Open
wants to merge 66 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
b51d445
Update BrotherPrinter.java
momzor Jan 30, 2017
5010a35
Update new Jar version 3.0.6 with 820NWB compat
Jan 30, 2017
810fd91
delete .idea
momzor Jan 30, 2017
9753249
adding 3.0 compatibilies and remove usb
Jan 31, 2017
bf2238a
Merge branch 'master' of https://github.com/momzor/cordova-brother-la…
Jan 31, 2017
442c45e
change pluggin id
Jan 31, 2017
ccade79
add libs armeabi-v7a and x86
Feb 22, 2017
5bf1da0
update plugin.xml
Feb 22, 2017
92ee371
update version and repo
Feb 22, 2017
98c1185
add a source file per lib
Feb 22, 2017
779492a
add bluetooth port
Feb 24, 2017
49c6ee1
update version
Feb 24, 2017
c42f0b9
set some permissions to false
Feb 28, 2017
ee961b8
Merge pull request #1 from ltrtom/master
momzor Mar 6, 2017
3b85fc8
testing bluetooth
Mar 7, 2017
0b2d7e5
adding bluetooth printer
Mar 7, 2017
9ce115d
adding wifi infra
Mar 7, 2017
0b2c793
adding wifi infra and numberOfCopies
Mar 8, 2017
45f22b0
adding cordova compat
Jul 25, 2017
a385b68
adding bluetooth permission and external storage intent
Jul 26, 2017
37b4916
[AA] initial working version for QL-710W Android
arcadius Aug 1, 2017
925e5e2
[AA] QL-710W Android with some simplification
arcadius Aug 2, 2017
a0725d3
[AA] QL-710W Android with some simplification
arcadius Aug 2, 2017
72745ed
[AA] QL-710W wrong log message fixed
arcadius Aug 2, 2017
374eb00
[AA] QL-710W including packages
arcadius Aug 2, 2017
d7f8a57
[AA] QL-710W including packages
arcadius Aug 2, 2017
6427c88
Merge pull request #1 from MenelicSoftware/feature/ql-710w-working-ve…
arcadius Aug 2, 2017
90e334f
Update plugin.xml
arcadius Aug 2, 2017
e6c415e
Update plugin.xml
arcadius Aug 2, 2017
80423d6
Update package.json
arcadius Aug 2, 2017
522d08d
Update README.md
arcadius Aug 2, 2017
132f631
[AA] handling base64 prefix
arcadius Aug 2, 2017
4c405b6
[AA] adding just a TODO
arcadius Aug 4, 2017
8ccb5ae
[AA] issue #2: Ability to lookup printer at runtime
arcadius Aug 10, 2017
15f3c8b
Merge pull request #3 from MenelicSoftware/feature/2-ability-to-looku…
arcadius Aug 10, 2017
e95c603
[AA] issue #2: docs update
arcadius Aug 11, 2017
35bc0bc
[AA] issue #2: docs update
arcadius Aug 11, 2017
2922443
passing in errocCallback
arcadius Aug 22, 2017
81026b1
issue with typescript style back quote :-)
arcadius Sep 1, 2017
1380f49
[AA] passing paperSize parameter to indicate label in printer. This i…
arcadius Jun 18, 2018
172ae3a
Merge branch 'dev' of https://github.com/gordol/cordova-brother-label…
arcadius Jun 18, 2018
73207f9
Merge branch 'gordol-dev' into dev
arcadius Jun 18, 2018
e4f5282
Merge pull request #7 from MenelicVisitor/dev
arcadius Jun 18, 2018
d29af15
Update plugin.xml
arcadius Jun 18, 2018
cce8ac3
Update plugin.xml
arcadius Jun 18, 2018
f00110b
making code compile for iOS and passing paper label as a variabke
arcadius Jun 22, 2018
6b22acd
making code compile for iOS and passing paper label as a variable
arcadius Jun 22, 2018
95ebb6c
Merge remote-tracking branch 'origin/dev' into dev
arcadius Jun 22, 2018
4cdf118
Update APPingModule.m
arcadius Jun 23, 2018
ecee4b3
Update BRBluetoothPrintOperation.h
arcadius Jun 23, 2018
88e52eb
Update BRBluetoothPrintOperation.m
arcadius Jun 23, 2018
d025ca0
Update printer.js
arcadius Jun 23, 2018
675e1cb
Update printer.js
arcadius Jun 23, 2018
01f633a
Update README.md
arcadius Jun 23, 2018
068033b
Delete PrintJobSetting.java
arcadius Jun 23, 2018
d463b95
Delete PrinterUtil.java
arcadius Jun 23, 2018
2a211f1
Merge pull request #8 from MenelicSoftware/dev
arcadius Jun 23, 2018
e9390bc
Revert "Dev"
arcadius Jun 23, 2018
2775f6a
Merge pull request #9 from MenelicSoftware/revert-8-dev
arcadius Jun 23, 2018
6a7d4ed
reverting unintentional binary libs update
arcadius Jun 24, 2018
c4975a3
removing MFI External accessory requirements
arcadius Jul 11, 2018
838de2b
Update plugin.xml
arcadius Nov 22, 2018
9f5339c
Update plugin.xml
arcadius Feb 24, 2019
51f4f99
Update plugin.xml
arcadius Feb 25, 2019
eb94b77
Update package.json
arcadius Feb 25, 2019
e6702db
Merge branch 'master' into dev
arcadius Mar 17, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.idea
.idea/
94 changes: 18 additions & 76 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Cordova Brother Label Printer Plugin

THANKS to Thomas Gordon Lowrey IV for his great work how saved us hours

Uses the Brother Print SDK for Android...

More info can be found here, including a list of compatible printers: http://www.brother.com/product/dev/mobile/android/index.htm
Expand All @@ -11,7 +13,7 @@ Already bundled is the following version: v3.0.4 (5/18/2016) which is in the `sr
In your Cordova project, run the following command to install the plugin.

```
cordova plugin add git+https://github.com/gordol/cordova-brother-label-printer.git
cordova plugin add https://github.com/MenelicSoftware/cordova-plugin-brother-label-printer.git
```

And then read [usage](#usage) below.
Expand All @@ -26,7 +28,7 @@ You can [read more about Android plugin development for Cordova here](https://co

Read here to [learn how to use Cordova Plugins](https://cordova.apache.org/docs/en/latest/guide/cli/index.html#add-plugins).

If you still have questions, please use the [issue tracker](https://github.com/3screens/cordova-brother-label-printer/issues). Please look at existing issues, and if your question is not answered yet, feel free to open a new issue and I'm happy to assist.
If you still have questions, please use the [issue tracker](https://github.com/MenelicSoftware/cordova-plugin-brother-label-printer.git/issues). Please look at existing issues, and if your question is not answered yet, feel free to open a new issue and I'm happy to assist.


## Target mobile printers:
Expand All @@ -45,95 +47,35 @@ PT-E800W, PT-D800W, PT-E850TKW
PT-P900W, PT-P950NW
```

__Tested models:__ `QL-720NW`, `QL-820NWB`
__Tested models:__ `QL-710W`, `QL-710NW`,`QL-820NWB`

(if you have tried this with other models, please update this list and send a pull request)

__NOTE:__ Currently, you will need to adjust the `modelName` variable in `src/android/BrotherPrinter.java`. It is the first variable in the `BrotherPrinter` class. This could be extended to be configured through config.xml or via a JS call, but it's currently hard-coded. Feel free to send a pull request to make the configuration more extensible...

## Supported interfaces (by this plugin):

* Wi-Fi (Infrastructure mode)
* Bluetooth (Android only, at the moment, iOS needs more work. See [PR10](https://github.com/gordol/cordova-brother-label-printer/pull/10)
* USB


## Usage

See here for JS interfaces to the plugin: `www/printer.js`

There are six available methods...

* [findNetworkPrinters(success, failure)](#findnetworkprinters)
* [findBluetoothPrinters(success, failure)](#findbluetoothprinters)
* [findPrinters(success, failure)](#findprinters)
* [setPrinter(printer, success, failure)](#setprinter)
* [printViaSDK(data, success)](#printviasdk)
* [sendUSBConfig(data, success)](#sendusbconfig)

### findNetworkPrinters

Upon success, [`findNetworkPrinters`](#findNetworkPrinters) will provide a list of printers that were discovered on the network (likely using WiFi). It is not considered an error for no printers to be found, and in this case the list will just be empty.

```typescript
function findNetworkPrinters(success: (printers: Printer[]) => void, failure: (reason: string) => void): void
## Supported interfaces (by this plugin):
```

### findBluetoothPrinters

Upon success, [`findBluetoothPrinters`](#findBluetoothPrinters) will provide a list of printers that were discovered that have already been paired via Bluetooth. It is not considered an error for no printers to be found, and in this case the list will just be empty.

```typescript
function findBluetoothPrinters(success: (printers: Printer[]) => void, failure: (reason: string) => void): void
Wi-Fi/Wired Ethernet (Infrastructure mode)
BlueTooth?
USB?
```

### findPrinters
_The SDK also has Bluetooth support, but this is not integrated currently. Pull requests are welcomed..._

[`findPrinters`](#findPrinters) is a convenience function that will perform the actions of both [`findNetworkPrinters`](#findNetworkPrinters) and [`findBluetoothPrinters`](#findBluetoothPrinters), and combine the the results into a single continuous list.

```typescript
function findPrinters(success: (printers: Printer[]) => void, failure: (reason: string) => void): void
```
## Usage

### setPrinter
See here for JS interfaces to the plugin: `www/printer.js`

must be called before [`printViaSDK`](#printViaSDK). It takes a single object that should be one of the objects returned from [`findNetworkPrinters`](#findNetworkPrinters), [`findBluetoothPrinters`](#findBluetoothPrinters), or [`findPrinters`](#findPrinters). Upon successfully setting the printer, the success callback
will be invoked. Otherwise, the error callback will be invoked with a string for an error message.
There is a single available method...

```typescript
function setPrinter(printer: Printer, success: () => void, failure: (reason: string) => void): void
```
printLabel(base64ImageOrPdfToPrint, {"numberOfCopies":1, "orientation":"LANDSCAPE", "labelName":"W62RB", "modelName":"QL-820NBW", "port":"NET"})

### printViaSDK

takes one parameter, which is a base64 encoded bitmap image. The result should be a status code that is passed directly from the SDK. The status codes are documnted in the Brother SDK Appendix in section 4.2.2.5.Error Code. If everything works, the response should be `"ERROR_NONE"`.

__Clarification__:
> A bitmap image in this case can be any image with an encoding that is supported by the platform.


```typescript
function printViaSDK(data: string, success: () => void): void
```
For the meaning of each of these parameters, please see http://www.brother.com/product/dev/mobile/android/index.htm

### sendUSBConfig

calls the Brother SDK's `printFile` method. The expected input is a string containing raw print commands, which is written to a temporary file in the app cache directory, and is then sent to the `printFile` method and deleted afterwards. You will need a device that supports USB-OTG and a USB-OTG cable. On first run the app will request USB permissions, and it should be saved after that for subsequent prints. As-is, this method is used to send raw commands in PCL (Printer Control Language) to the printer... For example, to configure the network settings of the printer, etc... You will need to reach out to Brother for documentation of the PCL commands. You can probably find them by searching for "[Brother Printer Command Reference](https://duckduckgo.com/?q=Brother+Printer+Command+Reference)" and appending your model number. This method could be extended easily to accept other types of file input, so you could, for example, print JPG images, etc... See here for a simple way to generate a PJL file to reconfigure the network: https://github.com/gordol/PJL-Generator
Currently, the last printer that is found will be the one targetted due to the way we're looping over the `netPrinters` array. This plugin could be extended to allow the user to select which printer they want to connect with... If this is desired, let me know, and I'll address when I get a chance, or better yet, send a pull request. The best way would either be to pass the printer IP/MAC to the printViaSDK method, or perhaps you could just pass an index to select the desired printer from the `netPrinters` list.


```typescript
function sendUSBConfig(data: string, success: () => void): void
```
### Interface Reference

```typescript
interface Printer {
model: string // Usually of the form 'QL_720NW' on Android
port: 'NET' | 'BLUETOOTH'
modelName: string // Usually of the form 'Brother QL-720NW'
ipAddress?: string
macAddress?: string
serialNumber?: string
nodeName?: string
location?: string
}
```
__sendUSBConfig__ calls the Brother SDK's `printFile` method. The expected input is a string containing raw print commands, which is written to a temporary file in the app cache directory, and is then sent to the `printFile` method and deleted afterwards. You will need a device that supports USB-OTG and a USB-OTG cable. On first run the app will request USB permissions, and it should be saved after that for subsequent prints. As-is, this method is used to send raw commands in PCL (Printer Control Language) to the printer... For example, to configure the network settings of the printer, etc... You will need to reach out to Brother for documentation of the PCL commands. You can probably find them by searching for "[Brother Printer Command Reference](https://duckduckgo.com/?q=Brother+Printer+Command+Reference)" and appending your model number. This method could be extended easily to accept other types of file input, so you could, for example, print JPG images, etc...
78 changes: 39 additions & 39 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
{
"name": "cordova-brother-label-printer",
"version": "0.0.4-dev",
"description": "Cordova hooks for Brother Print SDK",
"cordova": {
"id": "cordova-brother-label-printer",
"platforms": [
"android",
"ios"
]
},
"repository": {
"type": "git",
"url": "https://github.com/gordol/cordova-brother-label-printer"
},
"keywords": [
"brother",
"print",
"sdk",
"label",
"ecosystem:cordova",
"cordova-ios",
"cordova-android"
],
"engines": {
"cordova": ">=3.6.0",
"cordova-android": ">=6.0.0",
"android-sdk": ">=26",
"apple-ios": ">=10.0.0"
},
"author": "Thomas Gordon Lowrey IV",
"licenses": [{
"type": "MIT",
"url": "https://github.com/gordol/cordova-brother-label-printer/blob/master/LICENSE"
}],
"bugs": {
"url": "https://github.com/gordol/cordova-brother-label-printer/issues"
},
"homepage": "https://github.com/gordol/cordova-brother-label-printer#readme"
}
"name": "cordova-plugin-brother-label-printer",
"version": "1.0.1",
"description": "Cordova plugin for brother label printers",
"cordova": {
"id": "cordova-plugin-brother-label-printer",
"platforms": [
"android",
"ios"
]
},
"repository": {
"type": "git",
"url": "https://github.com/MenelicSoftware/cordova-plugin-brother-label-printer"
},
"keywords": [
"brother",
"print",
"sdk",
"label",
"ecosystem:cordova",
"cordova-ios",
"cordova-android"
],
"engines": {
"cordova": ">=3.6.0",
"cordova-android": ">=6.0.0",
"android-sdk": ">=26",
"apple-ios": ">=10.0.0"
},
"author": "Thomas Gordon Lowrey IV",
"licenses": [{
"type": "MIT",
"url": "https://github.com/MenelicSoftware/cordova-plugin-brother-label-printer/blob/master/LICENSE"
}],
"bugs": {
"url": "https://github.com/MenelicSoftware/cordova-plugin-brother-label-printer/issues"
},
"homepage": "https://github.com/MenelicSoftware/cordova-plugin-brother-label-printer#readme"
}
35 changes: 22 additions & 13 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-brother-label-printer"
version="0.0.4">
id="cordova-plugin-brother-label-printer"
version="1.0.1">

<name>BrotherPrinter</name>

<description>Cordova hooks for Brother Print SDK</description>
<repo>https://github.com/gordol/cordova-brother-label-printer.git</repo>
<repo>https://github.com/MenelicSoftware/cordova-plugin-brother-label-printer.git</repo>
<keywords>brother, sdk, print</keywords>
<license></license>

Expand Down Expand Up @@ -47,8 +47,10 @@
<config-file target="AndroidManifest.xml" parent="/manifest">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.BLUETOOTH" android:required="false" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:required="false" />
<!--
<uses-permission android:name="android.permission.BLUETOOTH" android:required="false" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:required="false" />
-->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.USB" android:required="false" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Expand All @@ -64,15 +66,22 @@
</feature>
</config-file>

<config-file target="*-Info.plist" parent="UISupportedExternalAccessoryProtocols">
<array>
<string>com.brother.ptcbp</string>
</array>
</config-file>

<!--
Commenting these ExternalAccesory configs to avoid app being rejected from app store:
MFi - Program Authorization
We are unable to post your app to the App Store at this time because your app has not been authorized by the accessory manufacturer to work with the MFi accessory.
Next Steps
To resolve this issue, please contact the accessory manufacturer to request your app be added to the MFi Product Plan form.
-->
<!--
<config-file target="*-Info.plist" parent="UISupportedExternalAccessoryProtocols">
<array>
<string>com.brother.ptcbp</string>
</array>
</config-file>
<framework src="ExternalAccessory.framework" />
-->
<framework src="src/ios/libs/BRPtouchPrinterKit.framework" custom="true" />
<framework src="ExternalAccessory.framework" />

<header-file src="src/ios/BRBluetoothPrintOperation.h" />
<source-file src="src/ios/BRBluetoothPrintOperation.m" />

Expand Down
Loading