Giter Club home page Giter Club logo

flutter_bluetooth_serial's Introduction

flutter_bluetooth_serial

pub package

Flutter basic implementation for Classical Bluetooth (only RFCOMM for now).

Features

The first goal of this project, started by @edufolly was making an interface for Serial Port Protocol (HC-05 Adapter). Now the plugin features:

  • Adapter status monitoring,

  • Turning adapter on and off,

  • Opening settings,

  • Discovering devices (and requesting discoverability),

  • Listing bonded devices and pairing new ones,

  • Connecting to multiple devices at the same time,

  • Sending and receiving data (multiple connections).

The plugin (for now) uses Serial Port profile for moving data over RFCOMM, so make sure there is running Service Discovery Protocol that points to SP/RFCOMM channel of the device. There could be max up to 7 Bluetooth connections.

For now there is only Android support.

Funding

Your contribution will help drive the development of quality tools for the Flutter and Dart developer community. Any amount will be appreciated. Thank you for your continued support!

BuyMeACoffee

PIX

Sua contribuição ajudará a impulsionar o desenvolvimento de ferramentas de qualidade para a comunidade de desenvolvedores Flutter e Dart. Qualquer quantia será apreciada. Obrigado pelo seu apoio contínuo!

PIX

Getting Started

Depending

# Add dependency to `pubspec.yaml` of your project.
dependencies:
  # ...
  flutter_bluetooth_serial: ^0.4.0

Installing

flutter pub get

Importing

import 'package:flutter_bluetooth_serial/flutter_bluetooth_serial.dart';

Usage

You should look to the Dart code of the library (mostly documented functions) or to the examples code.

// Some simplest connection :F
try {
    BluetoothConnection connection = await BluetoothConnection.toAddress(address);
    print('Connected to the device');

    connection.input.listen((Uint8List data) {
        print('Data incoming: ${ascii.decode(data)}');
        connection.output.add(data); // Sending data

        if (ascii.decode(data).contains('!')) {
            connection.finish(); // Closing connection
            print('Disconnecting by local host');
        }
    }).onDone(() {
        print('Disconnected by remote request');
    });
}
catch (exception) {
    print('Cannot connect, exception occured');
}

Note: Work is underway to make the communication easier than operations on byte streams. See #41 for discussion about the topic.

Examples

Check out example application with connections with both Arduino HC-05 and Raspberry Pi (RFCOMM) Bluetooth interfaces.

Main screen and options Discovery and connecting Simple chat with server Background connection

To-do list

  • Add some utils to easier manage BluetoothConnection (see discussion #41),
  • Allow connection method/protocol/UUID specification,
  • Listening/server mode,
  • Recognizing and displaying BluetoothClass of device,
  • Maybe integration with flutter_blue one day ;)

You might also want to check milestones.

Credits

After version 0.3.0 we have a lot of collaborators. If you would like to be credited, please send me an email.

flutter_bluetooth_serial's People

Contributors

afonsocraposo avatar againpsychox avatar bean5 avatar caijinglong avatar changjoo-park avatar codacy-badger avatar edufolly avatar fweissenb avatar harrylinatha avatar hmney avatar kechankrisna avatar mohiuddinm avatar nightscape avatar nirala96 avatar p13i avatar rafaelterada avatar rickcasson avatar rickdroio avatar riscue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flutter_bluetooth_serial's Issues

getBondedDevices throws [Failed resolution of: Landroidx/core/content/ContextCompat];

Hello!
The getBondedDevices call never finishes, it crashes the app.
I'm trying to get now connected device's address. I've gone through the lib code and failed to find this method anywhere so my idea was to get all the paired devices and find the one with BluetoothBondState.bound. IDK if this method gets paired devices or connected devices, this is what I'm testing / trying to figure out.
However... the initial call fails. This is me testing the method:
https://pastebin.com/5cdX052g

Again, I know. Async in build sux. I just wanna see the output.
This is the debug console output doe:
https://pastebin.com/tsvy0nEh

Manifest:
https://pastebin.com/PRG6vcDF

Tried flutter clean. Breakpoint just at the call says it has to be that call that breaks the app. Commenting it out works...
2 hours of googlng didn't help.
I'm running linux (obvious from debug message), live device Samsung J7, Android 9.1.
Any ideas?

EDIT: I don't know how Github "code" works but I don't like it. Moved it to mpastebin.

must be received once and sent once?

After receiving ,it must click “send” to receive the next message?
No matter how much the sender sends, it will not be printed automatically. It will only be printed once after clicking “send”.

Invoke-customs are only supported starting with android 0 --min-api 26

I was getting the issue outlined in the title when attempting to run the example included in the repo.

Googling the error message pointed me in the direction of this Stack Overflow thread:
https://stackoverflow.com/questions/49891730/invoke-customs-are-only-supported-starting-with-android-0-min-api-26

I had to add the following to the build.gradle file within "android > app".

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

Thought it might be worth adding to the readme in case anyone else encounters this issue.

Thanks!

Missing and mismatched data while reading.

I am working in an Application where it needs to read large amount data over Bluetooth SPP. When the app reads the data, it's actually not receiving all the data as expected. At first I thought it might be the issue with the device. But I tested the same functionality with a native Android app and it works without any issue.

I looked into the plugin source code and I added a log printing the buffer inside the onRead() function from the FlutterBluetoothSerialPlugin class. Surprisingly it receives the expected data from the device but at the flutter end the exact data is not getting send. The issue might be exist somewhere while sending the data from native code to flutter using Event Channel.

Steps:

  1. Data received in the onRead() function:
    2, 4, 91, 0, 0, 0, 0, 49, 57, 48, 57, 48, 51, 48, 56, 48, 48, 48, 48, 50, 53, 51, 51, 87, 65, 123, 20, 14, 64, 123, 20, 14, 64, 48, 48, 48, 48, 46, 48, 48, 48, 48, 83, 48, 48, 48, 48, 48, 46, 48, 48, 48, 48, 87, 51, 67, 3, 69, 1, 1, 49, 48, 51, 48, 48, 1, -51, -52, -20, 64, 102, 102, -54, 65, -51, -52, -84, 65, -118, 1, 0, 0, 0, 49, 57, 48, 57, 48, 51, 48, 56, 48, 48, 48, 48, 53, 48, 51, 51, 87, 65, 82, -72, 14, 64, -92, 112, 13, 64, 48, 48, 48, 48, 46, 48, 48, 48, 48, 83, 48, 48, 48, 48, 48, 46, 48, 48, 48, 48, 87, 51, 67, 3, 69, 1, 1, 49, 48, 51, 48, 48, 1, -51, -52, -20, 64, 102, 102, -54, 65, -51, -52, -84, 65, -120, 2, 0, 0, 0, 49, 57, 48, 57, 48, 51, 48, 56, 48, 48, 48, 48, 55, 53, 51, 51, 87, 65, 41, 92, 15, 64, -51, -52, 12, 64, 48, 48, 48, 48, 46, 48, 48, 48, 48, 83, 48, 48, 48, 48, 48, 46, 48, 48, 48, 48, 87, 51, 67, 3, 69, 1, 1, 49, 48, 51, 48, 48, 1, -51, -52, -20, 64, 102, 102, -54, 65, -51, -52, -84, 65, -112, 3, 0, 0, 0, 49, 57, 48, 57, 48, 51, 48, 56, 48, 48, 48, 49, 48, 48, 51, 51, 87, 65, 0, 0, 16, 64, -10, 40, 12, 64, 48, 48, 48, 48, 46, 48, 48, 48, 48, 83, 48, 48, 48, 48, 48, 46, 48, 48, 48, 48, 87, 51, 67, 3, 69, 1, 1, 49, 48, 51, 48, 48, 1, -51, -52, -20, 64, 102, 102, -54, 65, -51, -52, -84, 65, -121, 4, 0, 0, 0, 49, 57, 48, 57, 48, 51, 48, 56, 48, 48, 48, 49, 50, 53, 51, 51, 87, 65, -41, -93, 16, 64, 31, -123, 11, 64, 48, 48, 48, 48, 46, 48, 48, 48, 48, 83, 48, 48, 48, 48, 48, 46, 48, 48, 48, 48, 87, 51, 67, 3, 69, 1, 1, 49, 48, 51, 48, 48, 1, -51, -52, -20, 64, 102, 102, -54, 65, -51, -52, -84, 65, -114, 5, 0, 0, 0, 49, 57, 48, 57, 48, 51, 48, 56, 48, 48, 48, 49, 53, 48, 51, 51, 87, 65, -82, 71, 17, 64, 72, -31, 10, 64, 48, 48, 48, 48, 46, 48, 48, 48, 48, 83, 48, 48, 48, 48, 48, 46, 48, 48, 48, 48, 87, 51, 67, 3, 69, 1, 1, 49, 48, 51, 48, 48, 1, -51, -52, -20, 64, 102, 102, -54, 65, -51, -52, -84, 65, -115, 6, 0, 0, 0, 49, 57, 48, 57, 48, 51, 48, 56, 48, 48, 48, 49, 55, 53, 51, 51, 87, 65, -123, -21, 17, 64, 113, 61, 10, 64, 48, 48, 48, 48, 46, 48, 48, 48, 48, 83, 48, 48, 48, 48, 48, 46, 48, 48, 48, 48, 87, 51, 67

  2. Data sent from native to flutter using EventChannel.

  3. Data received in flutter connection.input.listen:
    2, 4, 91, 0, 0, 0, 0, 49, 57, 48, 57, 48, 51, 48, 56, 48, 48, 48, 48, 50, 53, 51, 51, 87, 65, 123, 20, 14, 64, 123, 20, 14, 64, 48, 48, 48, 48, 46, 48, 48, 48, 48, 83, 48, 48, 48, 48, 48, 46, 48, 48, 48, 48, 87, 51, 67, 3, 69, 1, 1, 49, 48, 51, 48, 48, 1, 205, 204, 236, 64, 102, 102, 202, 65, 205, 204, 172, 65, 138, 1, 0, 0, 0, 49, 57, 48, 57, 48, 51, 48, 56, 48, 48, 48, 48, 53, 48, 51, 51, 87, 65, 82, 184, 14, 64, 164, 112, 13, 64, 48, 48, 48, 48, 46, 48, 48, 48, 48, 83, 48, 48, 48, 48, 48, 46, 48, 48, 48, 48, 87, 51, 67, 3, 69, 1, 1, 49, 48, 51, 48, 48, 1, 205, 204, 236, 64, 102, 102, 202, 65, 205, 204, 172, 65, 136, 2, 0, 0, 0, 49, 57, 48, 57, 48, 51, 48, 56, 48, 48, 48, 48, 55, 53, 51, 51, 87, 65, 41, 92, 15, 64, 205, 204, 12, 64, 48, 48, 48, 48, 46, 48, 48, 48, 48, 83, 48, 48, 48, 48, 48, 46, 48, 48, 48, 48, 87, 51, 67, 3, 69, 1, 1, 49, 48, 51, 48, 48, 1, 205, 204, 236, 64, 102, 102, 202, 65, 205, 204, 172, 65, 144, 3, 0, 0, 0, 49, 57, 48, 57, 48, 51, 48, 56, 48, 48, 48, 49, 48, 48, 51, 51, 87, 65, 0

As you can see both the data are different.

Any help is appreciated. Thanks in advance.

Problem disconnecting HC-05 module

Hello,

I've made a little app to test the HC-05 module, there is no problem when connecting, but when i tried to disconnect the module remains connected. I'm using the following code to disconnect, with a modification from #50 to test it,

           RaisedButton(
                padding: EdgeInsets.all(10.0),
                child: Text('Desconectar'),
                onPressed: () {
                  print('TEST: canceling the connection');
                  connection.cancel().then((_) {
                    print('TEST: connection cancelled');
                  });
                  Navigator.pop(context, true);
                },
              ), 

Only the first print statement is executed.

requestEnable crashes app

Hello, trying out this package and wanted to turn on bluetooth with a button press, but when I do it the app just crashes every time.
Here is the code for that

RaisedButton(
                onPressed: () {
                  future() async {
                    await FlutterBluetoothSerial.instance.requestEnable();
                  }

                  future().then((_) => print('enabled'));
                },
              ),

dispose problem

Hi
I have some problem in dispose process;

I tried to disconnection process using button

  @override
  void dispose() {
    // TODO: implement dispose
    if(connection != null){
      connection.finish();
      connection = null;
    }
//    connection.dispose();
    super.dispose();
  }
Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: flutter_bluetooth_serial/read/1. Response ID: 0

How to disconnected bluetooth device?

Methods marked with @UiThread must be executed on the main thread.

When I try to connect to a paired HC-05 Module running on my Arduino. The example app just crashes with this stack trace

W/BluetoothAdapter(24727): getBluetoothService() called with no BluetoothManagerCallback
D/FlutterBluePlugin(24727): android.bluetooth.device.action.ACL_CONNECTED
E/FlutterBluePlugin(24727): Methods marked with @UiThread must be executed on the main thread. Current thread: AsyncTask #2
E/FlutterBluePlugin(24727): java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: AsyncTask #2
E/FlutterBluePlugin(24727): 	at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:605)
E/FlutterBluePlugin(24727): 	at io.flutter.embedding.engine.FlutterJNI.invokePlatformMessageResponseCallback(FlutterJNI.java:556)
E/FlutterBluePlugin(24727): 	at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:131)
E/FlutterBluePlugin(24727): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:225)
E/FlutterBluePlugin(24727): 	at io.github.edufolly.flutterbluetoothserial.FlutterBluetoothSerialPlugin.lambda$connect$0(FlutterBluetoothSerialPlugin.java:257)
E/FlutterBluePlugin(24727): 	at io.github.edufolly.flutterbluetoothserial.-$$Lambda$FlutterBluetoothSerialPlugin$52C5RUgoP_r70sgAnP8ZXC1Ysz0.run(Unknown Source:6)
E/FlutterBluePlugin(24727): 	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
E/FlutterBluePlugin(24727): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/FlutterBluePlugin(24727): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/FlutterBluePlugin(24727): 	at java.lang.Thread.run(Thread.java:764)
E/AndroidRuntime(24727): FATAL EXCEPTION: AsyncTask #2
E/AndroidRuntime(24727): Process: com.example.timecube, PID: 24727
E/AndroidRuntime(24727): java.lang.IllegalStateException: Reply already submitted
E/AndroidRuntime(24727): 	at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:126)
E/AndroidRuntime(24727): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:230)
E/AndroidRuntime(24727): 	at io.github.edufolly.flutterbluetoothserial.FlutterBluetoothSerialPlugin.lambda$connect$0(FlutterBluetoothSerialPlugin.java:260)
E/AndroidRuntime(24727): 	at io.github.edufolly.flutterbluetoothserial.-$$Lambda$FlutterBluetoothSerialPlugin$52C5RUgoP_r70sgAnP8ZXC1Ysz0.run(Unknown Source:6)
E/AndroidRuntime(24727): 	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
E/AndroidRuntime(24727): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AndroidRuntime(24727): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime(24727): 	at java.lang.Thread.run(Thread.java:764)
D/OSTracker(24727): OS Event: crash
D/AbstractTracker(24727): Event success
I/Process (24727): Sending signal. PID: 24727 SIG: 9
Lost connection to device.

discovery time can set?

Hi, can add a feature can user can customize the discovery timeout? the default timeout time is too short that can not find all ble devices

Utilities for ease data transmission trough connection

Here is issue to discuss form and expected syntax for the utilities which will be targeted in next milestone.

General propose for the utilities: ease communication between your Bluetooth devices over RFCOMM (serial) protocol.

Assumptions:

  • whole utilities must be optional, leaving raw byte streams available,
  • should be consuming raw streams or providing separate interface on BluetoothConnection,
  • there should be use example in the example app (might overwrite current chat example, since it is using a bit deprecated),
  • there might/should be related Arduino (for HC-05; C++) and Raspberry Pi (python?) code for handling the request-response on the other side,

There are several ways (which could be mixed):

  • breaking streams of packets of bytes to stream of bytes,
  • basic buffering,
  • packet system,
  • request-response manner,
  • parsing utilities/frameworks,

Connect after Disconnect Error

Trying to make a simple test with this lib connecting to a BT printer.

BluetoothConnection connection = await BluetoothConnection.toAddress(printerAddress);
connection.output.add(utf8.encode(text)); //actually prints the text on printer
...
connection.cancel();

on log I got the message:

D/FlutterBluePlugin(15353): Disconnected (id: 14)

But when I try to execute the same code it gives me the follow error:

I/flutter (15353): PlatformException(connect_error, read failed, socket might closed or timeout, read ret: -1, java.io.IOException: read failed, socket might closed or timeout, read ret: -1
I/flutter (15353): 	at android.bluetooth.BluetoothSocket.readAll(BluetoothSocket.java:774)
I/flutter (15353): 	at android.bluetooth.BluetoothSocket.readInt(BluetoothSocket.java:788)
I/flutter (15353): 	at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:411)
I/flutter (15353): 	at io.github.edufolly.flutterbluetoothserial.BluetoothConnection.connect(BluetoothConnection.java:57)
I/flutter (15353): 	at io.github.edufolly.flutterbluetoothserial.BluetoothConnection.connect(BluetoothConnection.java:64)
I/flutter (15353): 	at io.github.edufolly.flutterbluetoothserial.FlutterBluetoothSerialPlugin.lambda$onMethodCall$0(FlutterBluetoothSerialPlugin.java:880)
I/flutter (15353): 	at io.github.edufolly.flutterbluetoothserial.-$$Lambda$FlutterBluetoothSerialPlugin$ysyByl051NlOhDx-4TeZKtqb1pA.run(Unknown Source:10)
I/flutter (15353): 	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
I/flutter (15353): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)

Looks like it doesnt close the connection.
Any clue how to fix it?

Thanks

Build issue

I keep getting this error when i try to build the application, any idea why?

C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_bluetooth_serial-0.2.0\android\src\main\java\io\github\edufolly\flutterbluetoothserial\FlutterBluetoothSerialPlugin.java:13: error: package androidx.core.app does not exist
import androidx.core.app.ActivityCompat;
                        ^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_bluetooth_serial-0.2.0\android\src\main\java\io\github\edufolly\flutterbluetoothserial\FlutterBluetoothSerialPlugin.java:14: error: package androidx.core.content does not exist
import androidx.core.content.ContextCompat;
                            ^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_bluetooth_serial-0.2.0\android\src\main\java\io\github\edufolly\flutterbluetoothserial\FlutterBluetoothSerialPlugin.java:203: error: cannot find symbol
                                                ActivityCompat.startActivity(registrar.activity(), intent, null);

PlatformException when trying to connect to device.

Problem summary

Steps to reproduce

When trying to connect to a device with an address a platform exception is thrown.

Steps to reproduce

  1. Scan for devices to get a list.
  2. Stop scanning for devices.
  3. Try to connect to a device.

Screenshot 2019-08-19 at 17 50 19

Screenshot 2019-08-19 at 17 46 56

Environment

Flutter 1.7.8+hotfix.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 20e59316b8 (5 weeks ago) • 2019-07-18 20:04:33 -0700
Engine • revision fee001c93f
Tools • Dart 2.4.0

Using HC-10 BLE device.

This is working on IOS with Flutter Blue plugin.

Print Qr Code

Good Morning. I'm connecting to a thermal printer and trying to print a Qr Code. It's possible? Thank you

Example App crashes

I have installed the example app on Xiaomi Redmi note 4. If I click any buttons, the app crashes.

🔥 To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R".
An Observatory debugger and profiler on Redmi Note 4 is available at: http://127.0.0.1:51495/SnxI_e9IxJI=/
For a more detailed help message, press "h". To detach, press "d"; to quit, press "q".
V/BoostFramework(11199): BoostFramework() : mPerf = com.qualcomm.qti.Performance@689460a
E/flutter (11199): [ERROR:flutter/shell/platform/android/platform_view_android_jni.cc(40)] java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/app/ActivityCompat;
E/flutter (11199): at io.github.edufolly.flutterbluetoothserial.FlutterBluetoothSerialPlugin.onMethodCall(FlutterBluetoothSerialPlugin.java:433)
E/flutter (11199): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
E/flutter (11199): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
E/flutter (11199): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:643)
E/flutter (11199): at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (11199): at android.os.MessageQueue.next(MessageQueue.java:329)
E/flutter (11199): at android.os.Looper.loop(Looper.java:142)
E/flutter (11199): at android.app.ActivityThread.main(ActivityThread.java:6375)
E/flutter (11199): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (11199): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
E/flutter (11199): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)
E/flutter (11199): Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.core.app.ActivityCompat" on path: DexPathList[[zip file "/data/app/com.example.flutter_bluetooth_serial_example-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.flutter_bluetooth_serial_example-1/lib/arm64, /data/app/com.example.flutter_bluetooth_serial_example-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
E/flutter (11199): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:74)
E/flutter (11199): at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
E/flutter (11199): at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/flutter (11199): ... 11 more
E/flutter (11199):
F/flutter (11199): [FATAL:flutter/shell/platform/android/platform_view_android_jni.cc(77)] Check failed: CheckException(env).
F/libc (11199): Fatal signal 6 (SIGABRT), code -6 in tid 11199 (_serial_example)


Build fingerprint: 'xiaomi/mido/mido:7.0/NRD90M/V10.2.3.0.NCFMIXM:user/release-keys'
Revision: '0'
ABI: 'arm64'
pid: 11199, tid: 11199, name: _serial_example >>> com.example.flutter_bluetooth_serial_example <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: '[FATAL:flutter/shell/platform/android/platform_view_android_jni.cc(77)] Check failed: CheckException(env).
'
x0 0000000000000000 x1 0000000000002bbf x2 0000000000000006 x3 0000000000000008
x4 0000000000000036 x5 0000000000800000 x6 0000007f82cfa000 x7 0000000000000000
x8 0000000000000083 x9 ffffffffffffffdf x10 0000000000000000 x11 0000000000000001
x12 ffffffffffffffff x13 0000000000000000 x14 0000000000000000 x15 000a3ad29ece668e
x16 0000007f81d45ed0 x17 0000007f81cef510 x18 0000000072090ddc x19 0000007f82daeb48
x20 0000000000000006 x21 0000007f82daeaa0 x22 000000000000000b x23 0000007f55e4d1d8
x24 0000000000000031 x25 0000000000000001 x26 0000007f71738520 x27 0000007f7172b1a8
x28 0000007f7f6f8980 x29 0000007fd65fdc60 x30 0000007f81cec9a0
sp 0000007fd65fdc40 pc 0000007f81cef518 pstate 0000000060000000
backtrace:
#00 pc 000000000006b518 /system/lib64/libc.so (tgkill+8)
#1 pc 000000000006899c /system/lib64/libc.so (pthread_kill+64)
#2 pc 0000000000023ee8 /system/lib64/libc.so (raise+24)
#3 pc 000000000001c96c /system/lib64/libc.so (abort+52)
#4 pc 0000000000d34ca8 /data/app/com.example.flutter_bluetooth_serial_example-1/lib/arm64/libflutter.so (offset 0xd20000)
#5 pc 0000000000d2778c /data/app/com.example.flutter_bluetooth_serial_example-1/lib/arm64/libflutter.so (offset 0xd20000)
#6 pc 0000000000d25cb0 /data/app/com.example.flutter_bluetooth_serial_example-1/lib/arm64/libflutter.so (offset 0xd20000)
#7 pc 0000000000d6c294 /data/app/com.example.flutter_bluetooth_serial_example-1/lib/arm64/libflutter.so (offset 0xd20000)
#8 pc 0000000000d35754 /data/app/com.example.flutter_bluetooth_serial_example-1/lib/arm64/libflutter.so (offset 0xd20000)
#9 pc 0000000000d3a45c /data/app/com.example.flutter_bluetooth_serial_example-1/lib/arm64/libflutter.so (offset 0xd20000)
#10 pc 000000000001852c /system/lib64/libutils.so (_ZN7android6Looper9pollInnerEi+1032)
#11 pc 0000000000018074 /system/lib64/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+60)
#12 pc 00000000000f76a8 /system/lib64/libandroid_runtime.so (_ZN7android18NativeMessageQueue8pollOnceEP7_JNIEnvP8_jobjecti+48)
#13 pc 00000000022112b0 /system/framework/arm64/boot-framework.oat (offset 0x195e000) (android.os.MessageQueue.nativePollOnce+140)
#14 pc 0000000002212f30 /system/framework/arm64/boot-framework.oat (offset 0x195e000) (android.os.MessageQueue.next+236)
#15 pc 000000000220c8f8 /system/framework/arm64/boot-framework.oat (offset 0x195e000) (android.os.Looper.loop+340)
#16 pc 0000000001a1d284 /system/framework/arm64/boot-framework.oat (offset 0x195e000) (android.app.ActivityThread.main+592)
#17 pc 00000000000d2b68 /system/lib64/libart.so (art_quick_invoke_static_stub+600)
#18 pc 00000000000df5b0 /system/lib64/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+252)
#19 pc 000000000042991c /system/lib64/libart.so (_ZN3artL18InvokeWithArgArrayERKNS_33ScopedObjectAccessAlreadyRunnableEPNS_9ArtMethodEPNS_8ArgArrayEPNS_6JValueEPKc+108)
#20 pc 000000000042b48c /system/lib64/libart.so (_ZN3art12InvokeMethodERKNS_33ScopedObjectAccessAlreadyRunnableEP8_jobjectS4_S4_m+1188)
#21 pc 00000000003a3620 /system/lib64/libart.so (ZN3artL13Method_invokeEP7_JNIEnvP8_jobjectS3_S3+56)
#22 pc 00000000006730f8 /system/framework/arm64/boot.oat (offset 0x5a2000) (java.lang.reflect.Method.invoke+180)
#23 pc 00000000028e7440 /system/framework/arm64/boot-framework.oat (offset 0x195e000) (com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run+124)
#24 pc 00000000028e8810 /system/framework/arm64/boot-framework.oat (offset 0x195e000) (com.android.internal.os.ZygoteInit.main+1532)
#25 pc 00000000000d2b68 /system/lib64/libart.so (art_quick_invoke_static_stub+600)
#26 pc 00000000000df5b0 /system/lib64/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+252)
#27 pc 000000000042991c /system/lib64/libart.so (_ZN3artL18InvokeWithArgArrayERKNS_33ScopedObjectAccessAlreadyRunnableEPNS_9ArtMethodEPNS_8ArgArrayEPNS_6JValueEPKc+108)
#28 pc 0000000000429574 /system/lib64/libart.so (_ZN3art17InvokeWithVarArgsERKNS_33ScopedObjectAccessAlreadyRunnableEP8_jobjectP10_jmethodIDSt9__va_list+380)
#29 pc 0000000000344acc /system/lib64/libart.so (_ZN3art3JNI21CallStaticVoidMethodVEP7_JNIEnvP7_jclassP10_jmethodIDSt9__va_list+604)
#30 pc 00000000000a782c /system/lib64/libandroid_runtime.so
#31 pc 00000000000a9f2c /system/lib64/libandroid_runtime.so (_ZN7android14AndroidRuntime5startEPKcRKNS_6VectorINS_7String8EEEb+704)
#32 pc 000000000000226c /system/bin/app_process64
#33 pc 000000000001a794 /system/lib64/libc.so (__libc_init+88)
#34 pc 0000000000001ccc /system/bin/app_process64

How to resolve this?

Thank you.

read failed, socket might closed or timeout, read ret: -1

Error occurred while connecting to a paired device.

W/BluetoothAdapter(28901): getBluetoothService() called with no BluetoothManagerCallback
E/FlutterBluePlugin(28901): read failed, socket might closed or timeout, read ret: -1
E/FlutterBluePlugin(28901): java.io.IOException: read failed, socket might closed or timeout, read ret: -1
E/FlutterBluePlugin(28901): 	at android.bluetooth.BluetoothSocket.readAll(BluetoothSocket.java:741)
E/FlutterBluePlugin(28901): 	at android.bluetooth.BluetoothSocket.readInt(BluetoothSocket.java:753)
E/FlutterBluePlugin(28901): 	at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:375)
E/FlutterBluePlugin(28901): 	at io.github.edufolly.flutterbluetoothserial.FlutterBluetoothSerialPlugin.lambda$connect$0(FlutterBluetoothSerialPlugin.java:235)
E/FlutterBluePlugin(28901): 	at io.github.edufolly.flutterbluetoothserial.-$$Lambda$FlutterBluetoothSerialPlugin$52C5RUgoP_r70sgAnP8ZXC1Ysz0.run(lambda)
E/FlutterBluePlugin(28901): 	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
E/FlutterBluePlugin(28901): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
E/FlutterBluePlugin(28901): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
E/FlutterBluePlugin(28901): 	at java.lang.Thread.run(Thread.java:760)

Flutter Doctor

[✓] Flutter (Channel stable, v1.2.1, on Linux, locale en_GB.UTF-8)
    • Flutter version 1.2.1 at /home/chandu/Flutter
    • Framework revision 8661d8aecd (3 weeks ago), 2019-02-14 19:19:53 -0800
    • Engine revision 3757390fa4
    • Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /home/chandu/Android/Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • ANDROID_SDK_ROOT = /home/chandu/Android/Sdk
    • Java binary at: /opt/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
    • All Android licenses accepted.

[✓] Android Studio (version 3.3)
    • Android Studio at /opt/android-studio
    • Flutter plugin version 33.3.1
    • Dart plugin version 182.5215
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[✓] VS Code (version 1.31.1)
    • VS Code at /usr/share/code
    • Flutter extension version 2.24.0

[✓] Connected device (1 available)
    • Redmi Note 4 • 192.168.0.100:5555 • android-arm64 • Android 7.0 (API 24)

• No issues found!

Adding new feature in plugin

I'm new in flutter and wanted to add some new feature in this plugin ,

  1. Created a new eventchannel lib/flutter_bluetooth_serial.dart

static const EventChannel _discoveryChannel = const EventChannel('$namespace/discovery');

//Doubt : how to listen to List of bluetooth devices instead of single Map object
Stream<dynamic> onDiscovery() { return _discoveryChannel.receiveBroadcastStream().map((map) => BluetoothDevice.fromMap(map)); }

  1. wrote new event channel in FlutterBluetoothSerialPlugin class

`
private final StreamHandler discoveryStreamHandler = new StreamHandler() {

    List<Map<String, Object>> list = new ArrayList<>();

    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            Log.d("discoveryStreamHandler ","onReceive");
            final String action = intent.getAction();

            Log.d(TAG, action);

            if (BluetoothDevice.ACTION_FOUND.equals(action)) {
                  // Get the BluetoothDevice object from the Intent
    BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
    // Add the name and address to an array adapter to show in a ListView

    Map<String, Object> ret = new HashMap<>();
    ret.put("address", device.getAddress());
    ret.put("name", device.getName());
    ret.put("type", device.getType());
    list.add(ret);


    // Log.d("list",list.toString());
    discoverySink.success(ret);
            }else if(BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)){

/* want to return list here while listening to it getting error as "List not a subtype of map<dynamic,dynamic>
*/
// discoverySink.success(list);
}
}
};

    @Override
    public void onListen(Object o, EventSink eventSink) {
        discoverySink = eventSink;

          if (ContextCompat.checkSelfPermission(registrar.activity(),
                        Manifest.permission.ACCESS_COARSE_LOCATION)
                        != PackageManager.PERMISSION_GRANTED) {

                    ActivityCompat.requestPermissions(registrar.activity(),
                            new String[]{Manifest.permission.ACCESS_COARSE_LOCATION},
                            REQUEST_COARSE_LOCATION_PERMISSIONS);

//Doubt : what shall i return here?

                }
        Log.e("discoveryStreamHandler ","onListen"+ registrar.activeContext());
        registrar.activeContext().registerReceiver(mReceiver,
        new IntentFilter(BluetoothDevice.ACTION_FOUND));
        registrar.activeContext().registerReceiver(mReceiver,
                new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED));
                mBluetoothAdapter.startDiscovery();

     

       
    }

    @Override
    public void onCancel(Object o) {
        Log.d("discoveryStreamHandler", "onCancel");
        discoverySink = null;
        registrar.activity().unregisterReceiver(mReceiver);
    }
};`

Called from main.dart as
bluettoth.getdevices().listen.
I'm getting list of devices but have some doubt which i listed in code snippet. Please revert

Allow user to choose between normal and broadcast StreamController

I had to enter a page and opening a stream more times but i always got the error of bad state. I know that there are different ways to solve this issue, by either close the stream or make a broadcast controller. I actually solved the problem by modifying flutter ble serial library and change the controller they provided by a broadcast one. So i ask edufolly if it's possible for users to choose between those two configurations and if he might want to explain how to close correctly the stream, cause i tried and failed.
Thank you all in advance for the help.

Steps to reproduce

if you want to add a broadcast controller to the library, you open the bluetooth connection sheet and modify the controller by adding the broadcast method.

Get currently connected device and it's connection

Hello!
So this is my use case:
I'm building an BT controller app (big shock ik), however I don't want to do connecting or disconnecting atm in the app, so I use Android's built-in BT manager to do that. If device is connected when the app is opened, the status message is set accordingly.
I didn't find method for this anywhere in the lib's code, I did find the deprecated isConnected that gives wrong status.
I created this code for my app, and I can PR it if you think it's useful.
Atm, I'm just getting the bool status of connection but I'm considering getting the underlying connection object as well.
Speaking of which, I noticed BluetoothConnection does not have reference to connected BuetoothDevice. Adding that might be useful (for this UC at least).
Full feature supporting this might be:
-> getCurrentConnection method that returns BluetoothConnection object.
-> The object has reference to the device so it's name, address etc can be read
-> if method returns null, no device is currently connected
-> Errors to be handled accordingly, if device is connected but connection object can't be retrieved for example. Few others come to mind...
-> ....
-> Profit!

Thoughts?
If you like the idea, I'll do the PR, no worries.

Trying to connect to a turned off device gives a exception

If I try to connect to a turned off device I get the following error:

D/HWUIExtension(18400): MTKProgramCache.generateProgram: 562984313159681
D/HWUIExtension(18400): createProgram 0x0002000800000001, binary 0x95f21698, length 11759, format 37168 within 1848ns
W/ResourcesManager(18400): key.mResDir: /data/app/com.example.nexso-WbEriBSNsstF1_gci-xIvg==/base.apk, ignore idmapPath: /system/overlay/framework-res-overlay.apk
W/BluetoothAdapter(18400): getBluetoothService() called with no BluetoothManagerCallback
E/FlutterBluePlugin(18400): read failed, socket might closed or timeout, read ret: -1
E/FlutterBluePlugin(18400): java.io.IOException: read failed, socket might closed or timeout, read ret: -1
E/FlutterBluePlugin(18400): at android.bluetooth.BluetoothSocket.readAll(BluetoothSocket.java:685)
E/FlutterBluePlugin(18400): at android.bluetooth.BluetoothSocket.readInt(BluetoothSocket.java:697)
E/FlutterBluePlugin(18400): at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:374)
E/FlutterBluePlugin(18400): at io.github.edufolly.flutterbluetoothserial.FlutterBluetoothSerialPlugin.lambda$connect$0$FlutterBluetoothSerialPlugin(FlutterBluetoothSerialPlugin.java:248)
E/FlutterBluePlugin(18400): at io.github.edufolly.flutterbluetoothserial.-$$Lambda$FlutterBluetoothSerialPlugin$52C5RUgoP_r70sgAnP8ZXC1Ysz0.run(Unknown Source:6)
E/FlutterBluePlugin(18400): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
E/FlutterBluePlugin(18400): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
E/FlutterBluePlugin(18400): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
E/FlutterBluePlugin(18400): at java.lang.Thread.run(Thread.java:764)

Error while trying to connect to a turned off printer

Good Morning. I am using this plugin to connect to a printer and print. It works fine but when I try to print to a paired printer that is turned off, it generates an error. How can I check if the printer is turned off or not? Thanks

List<BluetoothDevice> devices = await bluetooth.getBondedDevices();
if (devices.length > 0) {
  macPadrao = p.getString('impressora');
  if (macPadrao != null) {
    device = devices.singleWhere((d) => d.address == macPadrao);
    if (device != null) {
      try {
        bool conectado = await bluetooth.isConnected;
        if (!conectado)
          await bluetooth.connect(device).then((d) {
            device.connected = d;
          }).catchError((error) {
            print(error.toString());
          });
      } catch (exception) {
        print(exception.toString());
      }
    }
  }
}

E/FlutterBluePlugin(10153): java.io.IOException: read failed, socket might closed or timeout, read ret: -1
E/FlutterBluePlugin(10153): at android.bluetooth.BluetoothSocket.readAll(Unknown Source:69)
E/FlutterBluePlugin(10153): at android.bluetooth.BluetoothSocket.readInt(Unknown Source:3)
E/FlutterBluePlugin(10153): at android.bluetooth.BluetoothSocket.connect(Unknown Source:123)
E/FlutterBluePlugin(10153): at io.github.edufolly.flutterbluetoothserial.FlutterBluetoothSerialPlugin.lambda$connect$0(FlutterBluetoothSerialPlugin.java:221)
E/FlutterBluePlugin(10153): at io.github.edufolly.flutterbluetoothserial.-$$Lambda$FlutterBluetoothSerialPlugin$52C5RUgoP_r70sgAnP8ZXC1Ysz0.run(Unknown Source:6)
E/FlutterBluePlugin(10153): at android.os.AsyncTask$SerialExecutor$1.run(Unknown Source:2)
E/FlutterBluePlugin(10153): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/FlutterBluePlugin(10153): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/FlutterBluePlugin(10153): at java.lang.Thread.run(Thread.java:764)
E/AndroidRuntime(10153): FATAL EXCEPTION: AsyncTask #2
E/AndroidRuntime(10153): Process: br.com.emdurb.talonarioeletronico, PID: 10153
E/AndroidRuntime(10153): java.lang.IllegalArgumentException: Unsupported value: java.io.IOException: read failed, socket might closed or timeout, read ret: -1
E/AndroidRuntime(10153): at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:293)
E/AndroidRuntime(10153): at io.flutter.plugin.common.StandardMethodCodec.encodeErrorEnvelope(StandardMethodCodec.java:70)
E/AndroidRuntime(10153): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:208)
E/AndroidRuntime(10153): at io.github.edufolly.flutterbluetoothserial.FlutterBluetoothSerialPlugin.lambda$connect$0(FlutterBluetoothSerialPlugin.java:229)
E/AndroidRuntime(10153): at io.github.edufolly.flutterbluetoothserial.-$$Lambda$FlutterBluetoothSerialPlugin$52C5RUgoP_r70sgAnP8ZXC1Ysz0.run(Unknown Source:6)
E/AndroidRuntime(10153): at android.os.AsyncTask$SerialExecutor$1.run(Unknown Source:2)
E/AndroidRuntime(10153): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AndroidRuntime(10153): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime(10153): at java.lang.Thread.run(Thread.java:764)
E/MQSEventManagerDelegate(10153): failed to get MQSService.
I/Process (10153): Sending signal. PID: 10153 SIG: 9

error: package androidx.core.content does not exist

Hello,
I seem to be can not compile with this plugin. I merely imported it to main.dart. Version is 0.0.5. It shows this error:


/opt/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_bluetooth_serial-0.0.5/android/src/main/java/io/github/edufolly/flutterbluetoothserial/FlutterBluetoothSerialPlugin.java:14: error: package androidx.core.content does not exist

After I put

android.enableJetifier=true
android.useAndroidX=true

to gradle.properties, it showed another error as below.

Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 18 declared in library [:flutter_bluetooth_serial] /home/lem0n/Projects/flutter/hello_world/build/flutter_bluetooth_serial/intermediates/merged_manifests/debug/processDebugManifest/merged/AndroidManifest.xml as the library might be using APIs not available in 16
  	Suggestion: use a compatible library with a minSdk of at most 16,
  		or increase this project's minSdk version to at least 18,
  		or use tools:overrideLibrary="io.github.edufolly.flutterbluetoothserial" to force usage (may lead to runtime failures)```

How can I solve this problem?

Stream Bytes

I have a device where i send some ascii commands and get a byte array as answer.
I implemented this with onRead() but the implemented onRead is a Stream of String

If i take this string and convert it to Uint8List it happens that I loose some zero values.
So my question:
Why do we use String instead of bytes?

If I change it to
Stream<Uint8List> onRead() => _readChannel.receiveBroadcastStream().map((buffer) => buffer);

and the implementation in run()-method to

while (true) {
                try {
                    bytes = mmInStream.read(buffer);
                    byte[] dst = Arrays.copyOf(buffer, bytes);
                    readSink.success(dst);
                } catch (NullPointerException e) {
                    break;
                } catch (IOException e) {
                    break;
                }
            }

it works like a charm for me.

Is there any reason to not using bytes?
If not I will make an PR to change (or extend with onReadBytes()?).

Formating bytes coming from onRead or Input and data always coming with "\r\n"

Below console information is coming from RFID Reader and it can read upto 500 of it at the same time but i noticed it always come with \r\n at the back when step over in debugging e.g EP: E2000015151001591070AC5F\r\n EP: E2007B037A3C4DF16D7AB537
and below when is the console messages:

I/flutter (10731): CS: .iv
I/flutter (10731): CS: .iv
I/flutter (10731): EP: 300833B2DDD9014000000000
I/flutter (10731): EP: E2000015151001591070AC5F
I/flutter (10731): EP: E2007B037A3C4DF16D7AB537
I/flutter (10731): EP: E2000015151001581070AC57
I/flutter (10731): EP: E2000015151002501200A272
I/flutter (10731): CS: .iv
I/flutter (10731): EP: 300833B2DDD9014000000000
I/flutter (10731): EP: E2000015151001591070AC5F
I/flutter (10731): EP: E2007B037A3C4DF16D7AB537
I/flutter (10731): EP: E2000015151001581070AC57
I/flutter (10731): EP: E2000015151002501200A272
I/flutter (10731): EP: E2000015151001271070AC1F
I/flutter (10731): EP: E2000015151001821060AEA7
I/flutter (10731): EP: E2000015151001580810C89C
I/flutter (10731): EP: 300833B2DDD9014000000000
I/flutter (10731): OK:

Thank You

Obtaining class of `BluetoothDevice`

To-do - feature for somekind of BluetoothClass/BluetoothDeviceClass as class in BluetoothDevice.

See:

To-do:

  • passing raw value of the class from platform API,
  • inteligent class for encapsulate raw class value,
  • nice icons for each class in example app device listing.

Get status of connections to devices connected outside current session (or app)

There is no way to get connection status of some device if the connection was started by other application (same for the system) or in other session of your app.

This may cause misunderstandings, while connecting to occupied remote channels will fail.

This issue thread is created to address this exact issue, but it was mentioned in some others.

when discovery,error occur in somecases like Key android.bluetooth.device.extra.RSSI expected Short but value was a java.lang.Integer.

Hi, sometimes when i discovery the devices, the console will print these error, it seems that the type assert error, below is error snapshot:

W/Bundle  ( 8928): Key android.bluetooth.device.extra.RSSI expected Short but value was a java.lang.Integer.  The default value -32768 was returned.
W/Bundle  ( 8928): Attempt to cast generated internal exception:
W/Bundle  ( 8928): java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Short
W/Bundle  ( 8928): 	at android.os.BaseBundle.getShort(BaseBundle.java:839)
W/Bundle  ( 8928): 	at android.os.Bundle.getShort(Bundle.java:733)
W/Bundle  ( 8928): 	at android.content.Intent.getShortExtra(Intent.java:6157)
W/Bundle  ( 8928): 	at io.github.edufolly.flutterbluetoothserial.FlutterBluetoothSerialPlugin$4.onReceive(FlutterBluetoothSerialPlugin.java:328)
W/Bundle  ( 8928): 	at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:1122)
W/Bundle  ( 8928): 	at android.os.Handler.handleCallback(Handler.java:755)
W/Bundle  ( 8928): 	at android.os.Handler.dispatchMessage(Handler.java:95)
W/Bundle  ( 8928): 	at android.os.Looper.loop(Looper.java:154)
W/Bundle  ( 8928): 	at android.app.ActivityThread.main(ActivityThread.java:6121)
W/Bundle  ( 8928): 	at java.lang.reflect.Method.invoke(Native Method)
W/Bundle  ( 8928): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
W/Bundle  ( 8928): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:795)

connect FATAL EXCEPTION / application crashes

When I try to connect using the sample on the README.MD, I get the following error:

E/AndroidRuntime(29972): java.lang.IllegalStateException: Reply already submitted
E/AndroidRuntime(29972): 	at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:135)
E/AndroidRuntime(29972): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:230)
E/AndroidRuntime(29972): 	at io.github.edufolly.flutterbluetoothserial.FlutterBluetoothSerialPlugin.lambda$connect$0(FlutterBluetoothSerialPlugin.java:260)
E/AndroidRuntime(29972): 	at io.github.edufolly.flutterbluetoothserial.-$$Lambda$FlutterBluetoothSerialPlugin$52C5RUgoP_r70sgAnP8ZXC1Ysz0.run(lambda)
E/AndroidRuntime(29972): 	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
E/AndroidRuntime(29972): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
E/AndroidRuntime(29972): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
E/AndroidRuntime(29972): 	at java.lang.Thread.run(Thread.java:762)
D/ViewRootImpl@63dfc94[MainActivity](29972): MSG_WINDOW_FOCUS_CHANGED 0
D/SurfaceView(29972): Relayout returned: oldFrame=[0,0][1440,2560] newFrame=[0,0][1440,2560] result=0x5 surface={Surface(name=null)/@0x6d52cf5 isValid=false 0}
D/ViewRootImpl@63dfc94[MainActivity](29972): mHardwareRenderer.destroy()#1
D/ViewRootImpl@63dfc94[MainActivity](29972): Relayout returned: oldFrame=[0,0][1440,2560] newFrame=[0,0][1440,2560] result=0x5 surface={isValid=false 0} surfaceGenerationChanged=true
D/ViewRootImpl@63dfc94[MainActivity](29972): mHardwareRenderer.destroy()#4
D/ViewRootImpl@63dfc94[MainActivity](29972): dispatchDetachedFromWindow
D/InputTransport(29972): Input channel destroyed: fd=84
I/System.out(29972): (HTTPLog)-Static: isSBSettingEnabled false
I/System.out(29972): (HTTPLog)-Static: isSBSettingEnabled false

Flutter doctor

[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Linux, locale en_US.UTF-8)
• Flutter version 1.7.8+hotfix.4 at /home/gilles/Documents/coding/applications/flutter
• Framework revision 20e59316b8 (5 weeks ago), 2019-07-18 20:04:33 -0700
• Engine revision fee001c93f
• Dart version 2.4.0

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /home/gilles/Android/Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = /home/gilles/Android/Sdk
• Java binary at: /home/gilles/Documents/coding/applications/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b16-5323222)
• All Android licenses accepted.

[✓] Android Studio (version 3.4)
• Android Studio at /home/gilles/Documents/coding/applications/android-studio
• Flutter plugin version 36.1.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b16-5323222)

[✓] VS Code (version 1.37.1)
• VS Code at /usr/share/code
• Flutter extension version 3.3.0

[✓] Connected device (1 available)
• SM G920F • 04157df4d4608f1b • android-arm64 • Android 7.0 (API 24)

中文乱码(Chinese garbled)

我给蓝牙设备发送中文字符时,蓝牙打印机出现中文乱码,字母和数字能正常打印,希望作者能为我解决问题,感谢。
When I sent Chinese characters to the bluetooth device, the bluetooth printer appeared Chinese scrambled codes. Letters and Numbers can be printed normally. I hope the author can solve the problem for me. Thank you!

Message other than String Type

Base on this portion of code,

class FlutterBluetoothSerial {
    ...
    Future<dynamic> write(String message) => _channel.invokeMethod('write', {'message': message});
    ...
}

message can only be submitted through String type..

Just to give you a use case, currently i am trying to make use of this plugin to sent byte data to a bluetooth printer. In native android, write method are represent in byte[] type if im not mistaken..

Connect Fails with exception S7 Edge

In the example code, after device search: OnTap function
I tried calling below:
onTap: () {
print(">>>OnTap");

            //try to connect
            final connection =  BluetoothConnection.toAddress(result.device.address);
            connection.then((value)=> print('Connected to the device'))
                      .catchError((error)=> print("Error: "+error));
            
            
            //Navigator.of(context).pop(result.device);

Commented the navigator pop

Exception has occurred.
PlatformException (PlatformException(connect_error, read failed, socket might closed or timeout, read ret: -1, java.io.IOException: read failed, socket might closed or timeout, read ret: -1
at android.bluetooth.BluetoothSocket.readAll(BluetoothSocket.java:821)
at android.bluetooth.BluetoothSocket.readInt(BluetoothSocket.java:833)
at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:458)
at io.github.edufolly.flutterbluetoothserial.BluetoothConnection.connect(BluetoothConnection.java:57)
at io.github.edufolly.flutterbluetoothserial.BluetoothConnection.connect(BluetoothConnection.java:64)
at io.github.edufolly.flutterbluetoothserial.FlutterBluetoothSerialPlugin.lambda$onMethodCall$0(FlutterBluetoothSerialPlugin.java:880)
at io.github.edufolly.flutterbluetoothserial.-$$Lambda$FlutterBluetoothSerialPlugin$ysyByl051NlOhDx-4TeZKtqb1pA.run(Unknown Source:10)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
))

EXAMPLE PROJECT

While i ran the example project it worked, but as soon as I connect to my thermal printer the app crashes with this log.
Also I'm using the latest version of flutter. 1.54

D/BluetoothAdapter(21892): isEnabled
D/BluetoothAdapter(21892): cancelDiscovery
D/BluetoothAdapter(21892): 241026643: getState(). Returning 12
W/BluetoothAdapter(21892): getBluetoothService() called with no BluetoothManagerCallback
D/FlutterBluePlugin(21892): android.bluetooth.device.action.ACL_CONNECTED
E/FlutterBluePlugin(21892): Methods marked with @UiThread must be executed on the main thread. Current thread: AsyncTask #2
E/FlutterBluePlugin(21892): java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: AsyncTask #2
E/FlutterBluePlugin(21892): 	at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:605)
E/FlutterBluePlugin(21892): 	at io.flutter.embedding.engine.FlutterJNI.invokePlatformMessageResponseCallback(FlutterJNI.java:556)
E/FlutterBluePlugin(21892): 	at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:129)
E/FlutterBluePlugin(21892): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:215)
E/FlutterBluePlugin(21892): 	at io.github.edufolly.flutterbluetoothserial.FlutterBluetoothSerialPlugin.lambda$connect$0(FlutterBluetoothSerialPlugin.java:251)
E/FlutterBluePlugin(21892): 	at io.github.edufolly.flutterbluetoothserial.-$$Lambda$FlutterBluetoothSerialPlugin$52C5RUgoP_r70sgAnP8ZXC1Ysz0.run(lambda)
E/FlutterBluePlugin(21892): 	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
E/FlutterBluePlugin(21892): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
E/FlutterBluePlugin(21892): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
E/FlutterBluePlugin(21892): 	at java.lang.Thread.run(Thread.java:761)
E/FlutterBluePlugin(21892): Reply already submitted
E/FlutterBluePlugin(21892): java.lang.IllegalStateException: Reply already submitted
E/FlutterBluePlugin(21892): 	at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:124)
E/FlutterBluePlugin(21892): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:220)
E/FlutterBluePlugin(21892): 	at io.github.edufolly.flutterbluetoothserial.FlutterBluetoothSerialPlugin.lambda$connect$0(FlutterBluetoothSerialPlugin.java:254)
E/FlutterBluePlugin(21892): 	at io.github.edufolly.flutterbluetoothserial.-$$Lambda$FlutterBluetoothSerialPlugin$52C5RUgoP_r70sgAnP8ZXC1Ysz0.run(lambda)
E/FlutterBluePlugin(21892): 	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
E/FlutterBluePlugin(21892): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
E/FlutterBluePlugin(21892): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
E/FlutterBluePlugin(21892): 	at java.lang.Thread.run(Thread.java:761)
E/AndroidRuntime(21892): FATAL EXCEPTION: AsyncTask #2
E/AndroidRuntime(21892): Process: io.github.edufolly.flutterbluetoothserialexample, PID: 21892
E/AndroidRuntime(21892): java.lang.IllegalStateException: Reply already submitted
E/AndroidRuntime(21892): 	at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:124)
E/AndroidRuntime(21892): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:220)
E/AndroidRuntime(21892): 	at io.github.edufolly.flutterbluetoothserial.FlutterBluetoothSerialPlugin.lambda$connect$0(FlutterBluetoothSerialPlugin.java:258)
E/AndroidRuntime(21892): 	at io.github.edufolly.flutterbluetoothserial.-$$Lambda$FlutterBluetoothSerialPlugin$52C5RUgoP_r70sgAnP8ZXC1Ysz0.run(lambda)
E/AndroidRuntime(21892): 	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
E/AndroidRuntime(21892): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
E/AndroidRuntime(21892): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
E/AndroidRuntime(21892): 	at java.lang.Thread.run(Thread.java:761)
I/SurfaceView(21892): updateWindow -- onWindowVisibilityChanged, visibility = 8, this = io.flutter.view.FlutterView{98d2f4 VFE...... .F...... 0,0-720,1280}
I/SurfaceView(21892): 10015476 Changes: creating=false format=false size=false visible=true left=false top=false mUpdateWindowNeeded=false mReportDrawNeeded=false redrawNeeded=false forceSizeChanged=false mVisible=true mRequestedVisible=false, this = io.flutter.view.FlutterView{98d2f4 VFE...... .F...... 0,0-720,1280}
I/SurfaceView(21892): 10015476 Cur surface: Surface(name=null)/@0x9378c8c, this = io.flutter.view.FlutterView{98d2f4 VFE...... .F...... 0,0-720,1280}
I/SurfaceView(21892): 10015476 New surface: Surface(name=null)/@0x9c1afd5, vis=false, frame=Rect(0, 0 - 720, 1280), this = io.flutter.view.FlutterView{98d2f4 VFE...... .F...... 0,0-720,1280}
I/SurfaceView(21892): 10015476 visibleChanged -- surfaceDestroyed, this = io.flutter.view.FlutterView{98d2f4 VFE...... .F...... 0,0-720,1280}
I/SurfaceView(21892): surfaceDestroyed callback +, this = io.flutter.view.FlutterView{98d2f4 VFE...... .F...... 0,0-720,1280}
D/Surface (21892): Surface::disconnect(this=0x9cb8ee00,api=1)
D/GraphicBuffer(21892): unregister, handle(0xa2e87460) (w:720 h:1280 s:720 f:0x1 u:0x000f02)
D/GraphicBuffer(21892): unregister, handle(0xa2e8c010) (w:720 h:1280 s:720 f:0x1 u:0x000f02)
D/GraphicBuffer(21892): unregister, handle(0xa2e8c550) (w:720 h:1280 s:720 f:0x1 u:0x000f02)
I/SurfaceView(21892): surfaceDestroyed callback -, this = io.flutter.view.FlutterView{98d2f4 VFE...... .F...... 0,0-720,1280}
V/SurfaceView(21892): Layout: x=0 y=0 w=720 h=1280, frame=Rect(0, 0 - 720, 1280), this = io.flutter.view.FlutterView{98d2f4 VFE...... .F...... 0,0-720,1280}
D/SurfaceView(21892): 10015476 windowPositionLostRT RT, frameNr = 0
D/Surface (21892): Surface::disconnect(this=0x9cb8e700,api=1)
D/GraphicBuffer(21892): unregister, handle(0xa2e87540) (w:720 h:1280 s:720 f:0x1 u:0x000f02)
D/GraphicBuffer(21892): unregister, handle(0xa2e87700) (w:720 h:1280 s:720 f:0x1 u:0x000f02)
D/GraphicBuffer(21892): unregister, handle(0xa2e8bec0) (w:720 h:1280 s:720 f:0x1 u:0x000f02)
I/SurfaceView(21892): updateWindow -- onDetachedFromWindow, this = io.flutter.view.FlutterView{98d2f4 VFE...... .F...... 0,0-720,1280}
D/WindowClient(21892): Remove from mViews: DecorView@988545c[MainActivity], this = android.view.WindowManagerGlobal@4dd7b19
E/ActivityThread(21892): Activity io.github.edufolly.flutterbluetoothserialexample.MainActivity has leaked IntentReceiver io.github.edufolly.flutterbluetoothserial.FlutterBluetoothSerialPlugin$1$1@8265c89 that was originally registered here. Are you missing a call to unregisterReceiver()?
E/ActivityThread(21892): android.app.IntentReceiverLeaked: Activity io.github.edufolly.flutterbluetoothserialexample.MainActivity has leaked IntentReceiver io.github.edufolly.flutterbluetoothserial.FlutterBluetoothSerialPlugin$1$1@8265c89 that was originally registered here. Are you missing a call to unregisterReceiver()?
E/ActivityThread(21892): 	at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:1201)
E/ActivityThread(21892): 	at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:951)
E/ActivityThread(21892): 	at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1314)
E/ActivityThread(21892): 	at android.app.ContextImpl.registerReceiver(ContextImpl.java:1294)
E/ActivityThread(21892): 	at android.app.ContextImpl.registerReceiver(ContextImpl.java:1288)
E/ActivityThread(21892): 	at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:586)
E/ActivityThread(21892): 	at io.github.edufolly.flutterbluetoothserial.FlutterBluetoothSerialPlugin$1.onListen(FlutterBluetoothSerialPlugin.java:408)
E/ActivityThread(21892): 	at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onListen(EventChannel.java:191)
E/ActivityThread(21892): 	at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onMessage(EventChannel.java:170)
E/ActivityThread(21892): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:88)
E/ActivityThread(21892): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:234)
E/ActivityThread(21892): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/ActivityThread(21892): 	at android.os.MessageQueue.next(MessageQueue.java:328)
E/ActivityThread(21892): 	at android.os.Looper.loop(Looper.java:148)
E/ActivityThread(21892): 	at android.app.ActivityThread.main(ActivityThread.java:6251)
E/ActivityThread(21892): 	at java.lang.reflect.Method.invoke(Native Method)
E/ActivityThread(21892): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
E/ActivityThread(21892): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
I/art     (21892): Enter while loop.
D/OpenGLRenderer(21892): ~CanvasContext() 0xa2ec5000

"startDiscovery()" makes app crash Fatal signal 6 (SIGABRT),

When calling the "startDiscovery()" function to obtain discoverable devices, the app crashes with error:

E/flutter (10018): [ERROR:flutter/shell/platform/android/platform_view_android_jni.cc(40)] java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/content/ContextCompat; E/flutter (10018): at io.github.edufolly.flutterbluetoothserial.FlutterBluetoothSerialPlugin.ensurePermissions(FlutterBluetoothSerialPlugin.java:988) E/flutter (10018): at io.github.edufolly.flutterbluetoothserial.FlutterBluetoothSerialPlugin.onMethodCall(FlutterBluetoothSerialPlugin.java:789) E/flutter (10018): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222) E/flutter (10018): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96) E/flutter (10018): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:643) E/flutter (10018): at android.os.MessageQueue.nativePollOnce(Native Method) E/flutter (10018): at android.os.MessageQueue.next(MessageQueue.java:328) E/flutter (10018): at android.os.Looper.loop(Looper.java:148) E/flutter (10018): at android.app.ActivityThread.main(ActivityThread.java:6339) E/flutter (10018): at java.lang.reflect.Method.invoke(Native Method) E/flutter (10018): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1084) E/flutter (10018): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:945) E/flutter (10018): Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.core.content.ContextCompat" on path: DexPathList[[zip file "/data/app/com.chargecontroller.android.abc-2/base.apk"],nativeLibraryDirectories=[/data/app/com.chargecontroller.android.abc-2/lib/arm, /data/app/com.chargecontroller.android.abc-2/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]] E/flutter (10018): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) E/flutter (10018): at java.lang.ClassLoader.loadClass(ClassLoader.java:380) E/flutter (10018): at java.lang.ClassLoader.loadClass(ClassLoader.java:312) E/flutter (10018): ... 12 more E/flutter (10018): F/flutter (10018): [FATAL:flutter/shell/platform/android/platform_view_android_jni.cc(77)] Check failed: CheckException(env). F/libc (10018): Fatal signal 6 (SIGABRT), code -6 in tid 10018 (ler.android.abc) Lost connection to device. Exited (sigterm)

Method not found: 'BluetoothConnection.toAddress

I am using version 0.2.2

Compiler message:
file:///Documents/coding/applications/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_bluetooth_serial-0.2.2/lib/FlutterBluetoothSerial.dart:245:52: Error: Method not found: 'BluetoothConnection.toAddress'.
    _defaultConnection = await BluetoothConnection.toAddress(address);
                                                   ^^^^^^^^^
lib/pages/tagReader/devicesList.dart:56:65: Error: Method not found: 'BluetoothConnection.toAddress'.
     BluetoothConnection connection = await BluetoothConnection.toAddress(device.address);
                                                                ^^^^^^^^^
Compiler failed on /Documents/coding/FLUTTER/appf/lib/main.dart
Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

Communication between 2 phones is not sent through

Hi,

I picked up 2 phones and after pairing them I can connect one to another. This is confirmed on the receiving phone because the "connect" button automatically changes to "disconnect".

However after a few seconds both buttons return to "connect", followed by a message on console.

D/FlutterBluePlugin(14133): android.bluetooth.device.action.ACL_DISCONNECTED
D/FlutterBluePlugin(14133): android.bluetooth.device.action.ACL_CONNECTED
D/FlutterBluePlugin(14133): android.bluetooth.device.action.ACL_DISCONNECTED
D/FlutterBluePlugin(14133): android.bluetooth.device.action.ACL_CONNECTED
D/FlutterBluePlugin(14133): android.bluetooth.device.action.ACL_DISCONNECTED
D/FlutterBluePlugin(14133): android.bluetooth.device.action.ACL_CONNECTED
D/FlutterBluePlugin(14133): android.bluetooth.device.action.ACL_DISCONNECTED

I also tried typing something and pressing send, but I couldn't make the message show up on the other phone.

Is "Access list of installed apps" permission necessary ?

After build flutter bluetooth serail into my app, and make a release package.
I found app ask for "Access list of installed apps" permission.
Is it necessary for bluetooth communication? what is the purpose for this permission?
Is possible to remove it?

Thank you.

Error while connecting bluetooth

While connecting Bluetooth with other device getting following error:

getBluetoothService() called with no BluetoothManagerCallback
D/FlutterBluePlugin(29010): android.bluetooth.device.action.ACL_CONNECTED
E/FlutterBluePlugin(29010): read failed, socket might closed or timeout, read ret: -1
E/FlutterBluePlugin(29010): java.io.IOException: read failed, socket might closed or timeout, read ret: -1
E/FlutterBluePlugin(29010): at android.bluetooth.BluetoothSocket.readAll(BluetoothSocket.java:686)
E/FlutterBluePlugin(29010): at android.bluetooth.BluetoothSocket.readInt(BluetoothSocket.java:698)
E/FlutterBluePlugin(29010): at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:375)
E/FlutterBluePlugin(29010): at io.github.edufolly.flutterbluetoothserial.FlutterBluetoothSerialPlugin.lambda$connect$0(FlutterBluetoothSerialPlugin.java:278)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.