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

write might no be found for low price printer #57

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ build/
*.ipr
*.iws
.idea/
example/ios/Podfile.lock
example/ios/Runner.xcodeproj/project.pbxproj
example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
example/macos/Podfile
example/macos/Flutter/GeneratedPluginRegistrant.swift
example/macos/Flutter/ephemeral/flutter_export_environment.sh
example/macos/Flutter/ephemeral/Flutter-Generated.xcconfig
24 changes: 12 additions & 12 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ PODS:
- blue_thermal_printer (0.0.1):
- Flutter
- Flutter (1.0.0)
- flutter_blue (0.0.1):
- flutter_blue_plus (0.0.1):
- Flutter
- flutter_blue/Protos (= 0.0.1)
- flutter_blue/Protos (0.0.1):
- flutter_blue_plus/Protos (= 0.0.1)
- flutter_blue_plus/Protos (0.0.1):
- Flutter
- Protobuf (~> 3.11.4)
- Protobuf (3.11.4)
- Protobuf (~> 3.11)
- Protobuf (3.20.0)

DEPENDENCIES:
- blue_print_pos (from `.symlinks/plugins/blue_print_pos/ios`)
- blue_thermal_printer (from `.symlinks/plugins/blue_thermal_printer/ios`)
- Flutter (from `Flutter`)
- flutter_blue (from `.symlinks/plugins/flutter_blue/ios`)
- flutter_blue_plus (from `.symlinks/plugins/flutter_blue_plus/ios`)

SPEC REPOS:
trunk:
Expand All @@ -29,16 +29,16 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/blue_thermal_printer/ios"
Flutter:
:path: Flutter
flutter_blue:
:path: ".symlinks/plugins/flutter_blue/ios"
flutter_blue_plus:
:path: ".symlinks/plugins/flutter_blue_plus/ios"

SPEC CHECKSUMS:
blue_print_pos: 23e8b4bede0fc07cd75b3257783523ca332bf3cb
blue_thermal_printer: e0f989c1ba2cae289f6472ebae0a22611958f2bc
blue_thermal_printer: c83405103d2c17f8d67aaa43fcff94df5d616a66
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
flutter_blue: eeb381dc4727a0954dede73515f683865494b370
Protobuf: 176220c526ad8bd09ab1fb40a978eac3fef665f7
flutter_blue_plus: 6787777145d615de01828f3a9fa423c3c702f0b3
Protobuf: 66e2f3b26a35e4cc379831f4ced538274ee4b923

PODFILE CHECKSUM: 7368163408c647b7eb699d0d788ba6718e18fb8d

COCOAPODS: 1.10.2
COCOAPODS: 1.11.3
8 changes: 4 additions & 4 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1020;
LastUpgradeCheck = 1300;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -355,7 +355,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 7NJGVJU8ZS;
DEVELOPMENT_TEAM = ZZ8H72CP6T;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down Expand Up @@ -484,7 +484,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 7NJGVJU8ZS;
DEVELOPMENT_TEAM = ZZ8H72CP6T;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -507,7 +507,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 7NJGVJU8ZS;
DEVELOPMENT_TEAM = ZZ8H72CP6T;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
25 changes: 16 additions & 9 deletions lib/blue_print_pos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import 'package:flutter_blue_plus/gen/flutterblueplus.pb.dart' as proto;
import 'package:image/image.dart' as img;
import 'package:qr_flutter/qr_flutter.dart';

//export 'package:blue_thermal_printer/blue_thermal_printer.dart';

class BluePrintPos {
BluePrintPos._() {
_bluetoothAndroid = blue_thermal.BlueThermalPrinter.instance;
bluetoothAndroid = blue_thermal.BlueThermalPrinter.instance;
_bluetoothIOS = flutter_blue.FlutterBluePlus.instance;
}

Expand All @@ -25,7 +27,7 @@ class BluePrintPos {
static const MethodChannel _channel = MethodChannel('blue_print_pos');

/// This field is library to handle in Android Platform
blue_thermal.BlueThermalPrinter? _bluetoothAndroid;
blue_thermal.BlueThermalPrinter? bluetoothAndroid;

/// This field is library to handle in iOS Platform
flutter_blue.FlutterBluePlus? _bluetoothIOS;
Expand Down Expand Up @@ -61,7 +63,7 @@ class BluePrintPos {
final blue_thermal.BluetoothDevice bluetoothDeviceAndroid =
blue_thermal.BluetoothDevice(
selectedDevice?.name ?? '', selectedDevice?.address ?? '');
await _bluetoothAndroid?.connect(bluetoothDeviceAndroid);
await bluetoothAndroid?.connect(bluetoothDeviceAndroid);
} else if (Platform.isIOS) {
_bluetoothDeviceIOS = flutter_blue.BluetoothDevice.fromProto(
proto.BluetoothDevice(
Expand Down Expand Up @@ -98,8 +100,8 @@ class BluePrintPos {
Duration timeout = const Duration(seconds: 5),
}) async {
if (Platform.isAndroid) {
if (await _bluetoothAndroid?.isConnected ?? false) {
await _bluetoothAndroid?.disconnect();
if (await bluetoothAndroid?.isConnected ?? false) {
await bluetoothAndroid?.disconnect();
}
_isConnected = false;
} else if (Platform.isIOS) {
Expand Down Expand Up @@ -191,7 +193,7 @@ class BluePrintPos {
await connect(selectedDevice!);
}
if (Platform.isAndroid) {
_bluetoothAndroid?.writeBytes(Uint8List.fromList(byteBuffer));
bluetoothAndroid?.writeBytes(Uint8List.fromList(byteBuffer));
} else if (Platform.isIOS) {
final List<flutter_blue.BluetoothService> bluetoothServices =
await _bluetoothDeviceIOS?.discoverServices() ??
Expand All @@ -202,9 +204,14 @@ class BluePrintPos {
);
final flutter_blue.BluetoothCharacteristic characteristic =
bluetoothService.characteristics.firstWhere(
(flutter_blue.BluetoothCharacteristic bluetoothCharacteristic) =>
bluetoothCharacteristic.properties.write,
);
(flutter_blue.BluetoothCharacteristic bluetoothCharacteristic) {
// write might no be found for low price printer
if (bluetoothCharacteristic.properties.write) {
return bluetoothCharacteristic.properties.write;
} else {
return bluetoothCharacteristic.properties.writeWithoutResponse;
}
});
await characteristic.write(byteBuffer, withoutResponse: true);
}
} on Exception catch (error) {
Expand Down