Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,15 @@
- Addresses old analysis warning.

## 2.2.4
- Adds 16KB support for Android. Special thanks to swapnilparmar-git for the change.
- Adds 16KB support for Android. Special thanks to swapnilparmar-git for the change.

## 2.3.0
- Upgrades iOS to Brother Print SDK 4.13.0.

- **iOS breaking/legacy:** Requires iOS 13.0+ (podspec `platform :ios` updated from 9.0 to 13.0).
- **iOS:** Replaces deprecated `sendPRNFileWithURL:` with `transferBinaryFiles:progress:` for .prn file printing (SDK 4.12.0+).
- **iOS:** Removes use of dropped APIs: `rotate180degrees` on RJ print settings (SDK 4.12.0), `forceVanishingMargin` on PT print settings (SDK 4.6.1). Use image rotation / print settings alternatives where needed.
- Host app must use a Brother iOS SDK 4.13.0–compatible pod (e.g. `BRLMPrinterKit_AB` or official Brother SDK at 4.13.0).

- **Android (4.6 → 4.13.1):** Replaces deprecated `orientation` and `rotate180` on `PrinterInfo` with `rotation` (SDK 4.6.4 deprecations). Rotation is derived from the same Dart `orientation` + `rotate180` for backward compatibility.
- **Android:** Stops setting `banishMargin` on `PrinterInfo` (no longer documented for SDK 4.13; PT forceVanishingMargin removed in iOS 4.6.1). Dart still sends `banishMargin`; it is ignored on Android.
3 changes: 2 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ rootProject.allprojects {
//url "https://rouninlabs.jfrog.io/artifactory/rounin-libs-external/"
url "https://artifacts.rouninlabs.com/rounin-libs-external/"
}
maven { url 'https://jitpack.io' }
}
}

Expand Down Expand Up @@ -58,6 +59,6 @@ android {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1'
implementation 'com.brother.sdk:printer:4.6.1@aar'
implementation 'com.github.johnvuko:BrotherPrintLibrary:4.13.1'
implementation 'com.brother.typeb:print:1.0.0'
}
2 changes: 1 addition & 1 deletion android/consumer-rules.pro
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
-keep class com.pauldemarco.flutter_blue.** { *; }
-keep class com.brother.ptouch.sdk.** { *; }
-keep class com.brother.** { *; }
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ fun printerInfofromMap(context:Context, flutterAssets: FlutterPlugin.FlutterAsse
localName = map["localName"] as String
lastConnectedAddress = map["lastConnectedAddress"] as String
paperSize = paperSizeFromMap(map["paperSize"] as Map<String, Any>)
orientation = orientationFromMap(map["orientation"] as Map<String, Any>)
// SDK 4.6.4+: orientation and rotate180 deprecated; use rotation instead.
rotation = rotationFromMap(
orientationMap = map["orientation"] as Map<String, Any>,
rotate180 = map["rotate180"] as Boolean
)
numberOfCopies = map["numberOfCopies"] as Int
halftone = halftoneFromMap(map["halftone"] as Map<String, Any>)
printMode = printModeFromMap(map["printMode"] as Map<String, Any>)
Expand All @@ -44,7 +48,6 @@ fun printerInfofromMap(context:Context, flutterAssets: FlutterPlugin.FlutterAsse
customPaperLength = map["customPaperLength"] as Int
customFeed = map["customFeed"] as Int
rjDensity = map["rjDensity"] as Int
rotate180 = map["rotate180"] as Boolean
peelMode = map["peelMode"] as Boolean
mirrorPrint = map["mirrorPrint"] as Boolean
paperPosition = alignFromMap(map["paperPosition"] as Map<String, Any>)
Expand Down Expand Up @@ -77,7 +80,7 @@ fun printerInfofromMap(context:Context, flutterAssets: FlutterPlugin.FlutterAsse
workPath = map["workPath"] as String
pjPaperKind = pjPaperKindFromMap(map["pjPaperKind"] as Map<String, Any>)
useLegacyHalftoneEngine = map["useLegacyHalftoneEngine"] as Boolean
banishMargin = map["banishMargin"] as Boolean
// banishMargin / forceVanishingMargin removed in SDK 4.6.1 (iOS); Android PrinterInfo no longer documents it for 4.13.
useCopyCommandInTemplatePrint = map["useCopyCommandInTemplatePrint"] as Boolean
this.timeout = timeout
setCustomPaperInfo(customPaperInfo)
Expand Down Expand Up @@ -169,6 +172,19 @@ fun orientationFromMap(map: Map<String, Any>): PrinterInfo.Orientation {
return PrinterInfo.Orientation.values().find { it.name == name }!!
}

/**
* Derives PrinterInfo.Rotation from orientation + rotate180 (SDK 4.6.4+ replacement for deprecated orientation/rotate180).
*/
fun rotationFromMap(orientationMap: Map<String, Any>, rotate180: Boolean): PrinterInfo.Rotation {
return when {
rotate180 -> PrinterInfo.Rotation.Rotate180
else -> when (orientationFromMap(orientationMap)) {
PrinterInfo.Orientation.LANDSCAPE -> PrinterInfo.Rotation.Rotate90
else -> PrinterInfo.Rotation.Rotate0
}
}
}

fun halftoneFromMap(map: Map<String, Any>): PrinterInfo.Halftone {
val id: Int = map["id"] as Int
val name: String = map["name"] as String
Expand Down
9 changes: 2 additions & 7 deletions ios/Classes/Method/BrotherUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ + (BRLMRJPrintSettings *)rjPrintSettingsFromMapWithValue:(NSDictionary<NSString
NSNumber * density = (NSNumber *)[map objectForKey:@"rjDensity"];

printerSettings.density = [BrotherUtils rjPrintDensityWithValue:density];
printerSettings.rotate180degrees = [[map objectForKey:@"rotate180"] isEqual:@(YES)];
// rotate180degrees was dropped in SDK 4.12.0; use imageRotation on print settings if rotation is needed.
printerSettings.peelLabel = [[map objectForKey:@"peelMode"]isEqual:@(YES)];
printerSettings.customPaperSize = customPaperSize;

Expand Down Expand Up @@ -890,10 +890,6 @@ + (BRLMRJPrintSettings *)rjPrintSettingsFromMapWithValue:(NSDictionary<NSString

printerSettings.halftoneThreshold = [(NSNumber *)[map objectForKey:@"thresholdingValue"] intValue];


NSUInteger numberOfCopies =
printerSettings.numCopies = (NSUInteger)[(NSNumber *)[map objectForKey:@"numberOfCopies"] integerValue];

printerSettings.numCopies = (NSUInteger)[(NSNumber *)[map objectForKey:@"numberOfCopies"] integerValue];

printerSettings.skipStatusCheck = [[map objectForKey:@"skipStatusCheck"] isEqual:@(YES)];
Expand Down Expand Up @@ -1320,7 +1316,7 @@ + (BRLMPTPrintSettings *)ptPrintSettingsFromMapWithValue:(NSDictionary<NSString

NSDictionary<NSString *, NSObject *> * dartResolution = (NSDictionary<NSString *, NSObject *> *)[map objectForKey:@"printQuality"];

bool forceVanishingMargin = [[map objectForKey:@"banishMargin"] isEqual:@(YES)];
// forceVanishingMargin / bBanishMargin was dropped in SDK 4.6.1.

NSDictionary<NSString*, NSObject*> * dartOrientation = (NSDictionary<NSString*, NSObject*> *)[map objectForKey:@"orientation"];

Expand All @@ -1332,7 +1328,6 @@ + (BRLMPTPrintSettings *)ptPrintSettingsFromMapWithValue:(NSDictionary<NSString
printerSettings.halfCut = halfCut;
printerSettings.specialTapePrint = specialTapePrint;
printerSettings.resolution = [BrotherUtils printResolutionFromMapWithValue:dartResolution];
printerSettings.forceVanishingMargin = forceVanishingMargin;
printerSettings.printOrientation = [BrotherUtils orientationFromMapWithValue:dartOrientation];


Expand Down
27 changes: 11 additions & 16 deletions ios/Classes/Method/PrintFileMethodCall.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,21 @@ - (void)execute {
NSURL * url = [NSURL fileURLWithPath:filePath];

NSString * extension = [url pathExtension];
BRLMPrintError * printError;
NSDictionary<NSString *, NSObject *> * printStatus;

if ([extension isEqualToString:@"prn"] ) {
// TODO Print PRN
// Call print method
printError = [printerDriver sendPRNFileWithURL:url];
if ([extension isEqualToString:@"prn"]) {
// SDK 4.12.0+ replaced sendPRNFileWithURL: with transferBinaryFiles:progress:
BRLMTransferResult *transferResult = [printerDriver transferBinaryFiles:@[ url ] progress:^(NSURL *current, int progress) {}];
BRLMPrintErrorCode code = (transferResult.code == BRLMTransferSummaryErrorAllSuccess)
? BRLMPrintErrorCodeNoError
: BRLMPrintErrorCodeUnknownError;
printStatus = [BrotherUtils printerStatusToMapWithError:code status:nil];
} else {
BRLMPrintError * printError = [printerDriver printImageWithURL:url settings:printerSettings];
printStatus = [BrotherUtils printerStatusToMapWithError:printError.code status:nil];
}
else {
// Print normal file
// Call print method
printError = [printerDriver printImageWithURL:url settings:printerSettings];
}



[printerDriver closeChannel];

// Notify status to Flutter.
NSDictionary<NSString *, NSObject *> * printStatus = [BrotherUtils printerStatusToMapWithError:printError.code status:nil];

_result(printStatus);


Expand Down
Binary file not shown.
Binary file modified ios/Lib/BRLMPrinterKit.framework/BRLMPrinterKit
Binary file not shown.
Binary file modified ios/Lib/BRLMPrinterKit.framework/BluetoothViewController.nib
Binary file not shown.
Binary file modified ios/Lib/BRLMPrinterKit.framework/CutterViewController.nib
Binary file not shown.
Binary file modified ios/Lib/BRLMPrinterKit.framework/ExtraFeedViewController.nib
Binary file not shown.
Binary file not shown.
41 changes: 28 additions & 13 deletions ios/Lib/BRLMPrinterKit.framework/Headers/BMSPrinterDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
// However, we CAN use the "BRPtouchPrinterKit.h" syntax, since we have added the BIL SDK .h
// files to our project.
//#import <BRPtouchPrinterKit/BRPtouchPrinterKit.h>
#import "BRPtouchPrinterKit.h"
#import <BRLMPrinterKit/BRPtouchPrinterKit.h>

#endif

#import "PrintSettings.h"
#import <BRLMPrinterKit/PrintSettings.h>

//*** NOTIFICATIONS
// Register for these if you wish to receive notifications for the following messages.
Expand Down Expand Up @@ -172,10 +172,11 @@
#define RET_CHANNEL_WRITE_ERROR -1009 // error occurred while writing data, such as if channel disconnected
#define RET_CHANNEL_READ_ERROR -1010 // error occurred while reading data, such as if channel disconnected

// This is used only by WIFI and FILE channel.
// In previous SDKs, RET_CHANNEL_CREATEERROR was used instead, but now we differentiate between these cases.
// NOTE: With WIFI channel especially, this can occur when user tries to start a job too quickly after a failure.
// Generally, using "isPrinterReady" API before calling openChannel can avoid this.
// It may be reported only when trying to open the channel.
// NOTE: With BT channel, it can be reported in open, send, or read, if error event occurs on stream.
// But I don't know how to cause it. Never seen it happen.
#define RET_CHANNEL_STREAMSTATUS_ERROR -1011

// These are used only for BT channel
Expand All @@ -199,6 +200,10 @@
#define RET_PRINTERSTATUS_ERROR_MEDIACANNOTBEFED -1021 // This is different from media empty. Treated as an error.
#define RET_PRINTERSTATUS_ERROR_UNKNOWNERROR -1022 // If status response processor gets unhandled error

//** 6/8/23: Added NEW error codes. Not changing old constants above, to be safe.
// This occurs if "app switch" in middle of BT transfer (if no app support for background processing).
// NOTE: It does not seem to happen on WIFI.
#define RET_CHANNEL_STREAM_END_OCCURRED -1023

// *************************************************************************************

Expand Down Expand Up @@ -464,22 +469,16 @@ typedef enum
timeout:(int)nTimeout;


// "wrappers" for isPrinterReady and getPTStatus.
// * isPrinterReady is useful to check for connectivity before attempting to print.
// "wrapper" for getPTStatus.
// * getPTStatus allows to you determine things like the actual connected model, paper inserted, cover open, etc.
// Refer to the BRPtouchSDK documentation for more details about the format and meaning of the status response.

// TAG: REMOVE_BRPTOUCH_SDK
// When using the "RemoveBRPtouchSDK" framework, isPrinterReady and getPTStatus are NOT supported
// When using the "RemoveBRPtouchSDK" framework, getPTStatus is NOT supported
// for the WIFI channel, because WIFI channel requires using the BRPtouchSDK API.
// However, for the Bluetooth channel, these functions are implemented internally to the BMS SDK, so you may still
// use these two APIs.

- (BOOL)isPrinterReady:(PRINTERMODEL)model
channelType:(CHANNELTYPE)channelType
channelString:(NSString *)channelString; // IPAddress or BTDeviceName

#ifdef REMOVE_BRPTOUCH_SDK
// Need this struct from other SDK when using our own getPTStatus implementation for Bluetooth.
typedef struct _PTSTATUSINFO {
Byte byHead; // Head mark
Byte bySize; // Size
Expand Down Expand Up @@ -527,6 +526,22 @@ typedef struct _PTSTATUSINFO {
- (CGRect) getPrintableRectFromCurrentSettings;
- (CGRect) getPaperRectFromCurrentSettings;

//********************************************************************************
// detectPrinterResolutionForModel
// Used to determine resolution of print head installed to TD23xx models ONLY
// 203, 300 models have different byModelCode in Status Response
// Each of these models supports only 1 resolution at a time.
//
// RETURNS:
// * RET_TRUE on success, detectedResolution is VALID
// * Other error code if FAILURE. detectedResolution is INVALID
- (int) detectPrinterResolutionForModel:(PRINTERMODEL)model
channelType:(CHANNELTYPE)channelType
channelString:(NSString *)channelString // IPAddress or BTDeviceName
detectedResolution:(RESOLUTION *)pResolution;
//********************************************************************************


//********************************************************************************
// SIMPLE APIs
//
Expand Down
112 changes: 70 additions & 42 deletions ios/Lib/BRLMPrinterKit.framework/Headers/BMSPrinterKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,52 +8,80 @@


#ifndef REMOVE_BRPTOUCH_SDK
#import "BRPtouchPrinterKit.h"
#import <BRLMPrinterKit/BRPtouchPrinterKit.h>
#endif

#import "BMSPrinterDriver.h"
#import <BRLMPrinterKit/BMSPrinterDriver.h>

#import "PrintSettings.h"
#import "GenericPocketJetPrintSettings.h"
#import "PJ673PrintSettings.h"
#import "PJ763MFiPrintSettings.h"
#import "PJ773PrintSettings.h"
#import "GenericMobileLabelModelPrintSettings.h"
#import "RJ4030AiPrintSettings.h"
#import "RJ4040PrintSettings.h"
#import "RJ4230BPrintSettings.h"
#import "RJ4250WBPrintSettings.h"
#import "RJ3050PrintSettings.h"
#import "RJ3050AiPrintSettings.h"
#import "RJ3150PrintSettings.h"
#import "RJ3150AiPrintSettings.h"
#import "TD2120NPrintSettings.h"
#import "TD2130NPrintSettings.h"
#import "RJ2050PrintSettings.h"
#import "RJ2140PrintSettings.h"
#import "RJ2150PrintSettings.h"
#import "TD4550DNWBPrintSettings.h"
#import <BRLMPrinterKit/PrintSettings.h>
#import <BRLMPrinterKit/GenericPocketJetPrintSettings.h>
#import <BRLMPrinterKit/PJ673PrintSettings.h>
#import <BRLMPrinterKit/PJ763MFiPrintSettings.h>
#import <BRLMPrinterKit/PJ773PrintSettings.h>
#import <BRLMPrinterKit/PJ862PrintSettings.h>
#import <BRLMPrinterKit/PJ863PrintSettings.h>
#import <BRLMPrinterKit/PJ883PrintSettings.h>
#import <BRLMPrinterKit/GenericMobileLabelModelPrintSettings.h>
#import <BRLMPrinterKit/RJ4030AiPrintSettings.h>
#import <BRLMPrinterKit/RJ4040PrintSettings.h>
#import <BRLMPrinterKit/RJ4230BPrintSettings.h>
#import <BRLMPrinterKit/RJ4250WBPrintSettings.h>
#import <BRLMPrinterKit/RJ3050PrintSettings.h>
#import <BRLMPrinterKit/RJ3050AiPrintSettings.h>
#import <BRLMPrinterKit/RJ3150PrintSettings.h>
#import <BRLMPrinterKit/RJ3150AiPrintSettings.h>
#import <BRLMPrinterKit/RJ3230BPrintSettings.h>
#import <BRLMPrinterKit/RJ3250WBPrintSettings.h>
#import <BRLMPrinterKit/RJ2050PrintSettings.h>
#import <BRLMPrinterKit/RJ2140PrintSettings.h>
#import <BRLMPrinterKit/RJ2150PrintSettings.h>
#import <BRLMPrinterKit/TD2120NPrintSettings.h>
#import <BRLMPrinterKit/TD2125NPrintSettings.h>
#import <BRLMPrinterKit/TD2125NWBPrintSettings.h>
#import <BRLMPrinterKit/TD2130NPrintSettings.h>
#import <BRLMPrinterKit/TD2135NPrintSettings.h>
#import <BRLMPrinterKit/TD2135NWBPrintSettings.h>
#import <BRLMPrinterKit/TD2320DPrintSettings.h>
#import <BRLMPrinterKit/TD2320DFPrintSettings.h>
#import <BRLMPrinterKit/TD2350DPrintSettings.h>
#import <BRLMPrinterKit/TD2350DFPrintSettings.h>
#import <BRLMPrinterKit/TD2350DSAPrintSettings.h>
#import <BRLMPrinterKit/TD4550DNWBPrintSettings.h>

#import "PrintSettingsViewController.h"
#import "GenericPocketJetPrintSettingsViewController.h"
#import "PJ673PrintSettingsViewController.h"
#import "PJ763MFiPrintSettingsViewController.h"
#import "PJ773PrintSettingsViewController.h"
#import "GenericMobileLabelModelPrintSettingsViewController.h"
#import "RJ4030AiPrintSettingsViewController.h"
#import "RJ4040PrintSettingsViewController.h"
#import "RJ4230BPrintSettingsViewController.h"
#import "RJ4250WBPrintSettingsViewController.h"
#import "RJ3050PrintSettingsViewController.h"
#import "RJ3050AiPrintSettingsViewController.h"
#import "RJ3150PrintSettingsViewController.h"
#import "RJ3150AiPrintSettingsViewController.h"
#import "TD2120NPrintSettingsViewController.h"
#import "TD2130NPrintSettingsViewController.h"
#import "RJ2050PrintSettingsViewController.h"
#import "RJ2140PrintSettingsViewController.h"
#import "RJ2150PrintSettingsViewController.h"
#import "TD4550DNWBPrintSettingsViewController.h"
#import <BRLMPrinterKit/PrintSettingsViewController.h>
#import <BRLMPrinterKit/GenericPocketJetPrintSettingsViewController.h>
#import <BRLMPrinterKit/PJ673PrintSettingsViewController.h>
#import <BRLMPrinterKit/PJ763MFiPrintSettingsViewController.h>
#import <BRLMPrinterKit/PJ773PrintSettingsViewController.h>
#import <BRLMPrinterKit/PJ862PrintSettingsViewController.h>
#import <BRLMPrinterKit/PJ863PrintSettingsViewController.h>
#import <BRLMPrinterKit/PJ883PrintSettingsViewController.h>
#import <BRLMPrinterKit/GenericMobileLabelModelPrintSettingsViewController.h>
#import <BRLMPrinterKit/RJ4030AiPrintSettingsViewController.h>
#import <BRLMPrinterKit/RJ4040PrintSettingsViewController.h>
#import <BRLMPrinterKit/RJ4230BPrintSettingsViewController.h>
#import <BRLMPrinterKit/RJ4250WBPrintSettingsViewController.h>
#import <BRLMPrinterKit/RJ3050PrintSettingsViewController.h>
#import <BRLMPrinterKit/RJ3050AiPrintSettingsViewController.h>
#import <BRLMPrinterKit/RJ3150PrintSettingsViewController.h>
#import <BRLMPrinterKit/RJ3150AiPrintSettingsViewController.h>
#import <BRLMPrinterKit/RJ3230BPrintSettingsViewController.h>
#import <BRLMPrinterKit/RJ3250WBPrintSettingsViewController.h>
#import <BRLMPrinterKit/RJ2050PrintSettingsViewController.h>
#import <BRLMPrinterKit/RJ2140PrintSettingsViewController.h>
#import <BRLMPrinterKit/RJ2150PrintSettingsViewController.h>
#import <BRLMPrinterKit/TD2120NPrintSettingsViewController.h>
#import <BRLMPrinterKit/TD2125NPrintSettingsViewController.h>
#import <BRLMPrinterKit/TD2125NWBPrintSettingsViewController.h>
#import <BRLMPrinterKit/TD2130NPrintSettingsViewController.h>
#import <BRLMPrinterKit/TD2135NPrintSettingsViewController.h>
#import <BRLMPrinterKit/TD2135NWBPrintSettingsViewController.h>
#import <BRLMPrinterKit/TD2320DPrintSettingsViewController.h>
#import <BRLMPrinterKit/TD2320DFPrintSettingsViewController.h>
#import <BRLMPrinterKit/TD2350DPrintSettingsViewController.h>
#import <BRLMPrinterKit/TD2350DFPrintSettingsViewController.h>
#import <BRLMPrinterKit/TD2350DSAPrintSettingsViewController.h>
#import <BRLMPrinterKit/TD4550DNWBPrintSettingsViewController.h>

@interface BMSPrinterKit : NSObject

Expand Down
Loading