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

not work with printer MPT-II #74

Open
YouSour opened this issue Nov 1, 2022 · 2 comments
Open

not work with printer MPT-II #74

YouSour opened this issue Nov 1, 2022 · 2 comments

Comments

@YouSour
Copy link

YouSour commented Nov 1, 2022

hi, i just text example code it look like it doesn't with printer MPT-II , it got an error below
Screen Shot 2022-11-01 at 12 05 57 PM

@ankush-ppie
Copy link

ankush-ppie commented Dec 25, 2022

Hi @YouSour

I also face same issue with iOS.
Please use this library or add code in your forked library.

lib/blue_print_pos.dart

Remove this code:

final flutter_blue.BluetoothCharacteristic characteristic =
            bluetoothService.characteristics.firstWhere(
          (flutter_blue.BluetoothCharacteristic bluetoothCharacteristic) =>
              bluetoothCharacteristic.properties.write,
        );
await characteristic.write(byteBuffer, withoutResponse: true);

Add this code:

final List<flutter_blue.BluetoothCharacteristic>
            writableCharacteristics = bluetoothService.characteristics
                .where((flutter_blue.BluetoothCharacteristic
                        bluetoothCharacteristic) =>
                    bluetoothCharacteristic.properties.write == true)
                .toList();
        if (writableCharacteristics.isNotEmpty) {
          await writableCharacteristics[0]
              .write(byteBuffer, withoutResponse: true);
        } else {
          final List<flutter_blue.BluetoothCharacteristic>
              writableWithoutResponseCharacteristics = bluetoothService
                  .characteristics
                  .where((flutter_blue.BluetoothCharacteristic
                          bluetoothCharacteristic) =>
                      bluetoothCharacteristic.properties.writeWithoutResponse ==
                      true)
                  .toList();
          if (writableWithoutResponseCharacteristics.isNotEmpty) {
            await writableWithoutResponseCharacteristics[0]
                .write(byteBuffer, withoutResponse: true);
          }
        }

Reference:
Screenshot 2022-12-25 at 9 03 59 AM

@YouSour
Copy link
Author

YouSour commented Dec 26, 2022

@ankush-ppie ok, i'll test it later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants