pauldemarco / flutter_blue

Bluetooth plugin for Flutter
BSD 3-Clause "New" or "Revised" License
2.37k stars 1.23k forks source link

Cant find any devices while flutter blue scanning #336

Open luissouza opened 5 years ago

luissouza commented 5 years ago

I try to find the devices with de oficial example: https://github.com/pauldemarco/flutter_blue/tree/master/example

I have several devices (BLE) that should be listed, but they NEVER appear. What am i doing wrong? Please, help me!

All the devices are (BLE).

gumbypp commented 5 years ago

Have you used another app (ex: LightBlue) to verify that your device can discover these devices?

luissouza commented 5 years ago

Have you used another app (ex: LightBlue) to verify that your device can discover these devices?

@gumbypp yes! Not appear to, why flutter_blue only appear BLE devices? I r

SzymonGalazka commented 5 years ago

I have the same issue. I tried with LG G6 with the example code and it shows nothing. Same if I search for paired devices. My devices are listed on LightBlue and on app built on top of flutter_bluetooth_serial.

scanForDevices() {

print('list of paired devices');
flutterBlue.connectedDevices.asStream().listen((paired) {
  print('paired device: $paired');
});
setState(() {
  _isScanning = true;
});
scanSubscription =
    flutterBlue.scan(timeout: Duration(seconds: 20)).listen((scanResult) {
  var device = scanResult.device;
  print('${device.name} found! rssi: ${scanResult.rssi}');
}, onDone: _stopScan);
scanSubscription.cancel();

} _logs: I/flutter (21110): list of paired devices D/BluetoothManager(21110): getConnectedDevices D/FlutterBluePlugin(21110): mGattServers size: 0 D/BluetoothAdapter(21110): isLeEnabled(): ON D/BluetoothLeScanner(21110): onScannerRegistered() - status=0 scannerId=5 mScannerId=0 I/flutter (21110): paired device: []

RuijinYao commented 4 years ago

I also encountered the same situation, but I can search for the device after I open the location of the phone.

hicnar commented 4 years ago

Same thing here, just one bluetooth device gets detected although plenty are on and visible for pairing. Tried all available ScanModes but no progress @RuijinYao by opening the location.. do you mean giving your app the location permission? To be honest after checking multiple BLE libraries and apps (LightBlue included) I am beginning to wonder if some manufacturers do something specific to prevent that their devices are detectable by anything other than the built in OS bluetooth software.

alejo9719 commented 4 years ago

Same problem

Skalate commented 4 years ago

Me too, and I try agin by other bluetooth packages. but no one can work normally.

KushalRathore09 commented 4 years ago

HI Team ,
 I am also facing the same problem. My use case is I am trying to connect bluetooth scanner device (Socket 7XI[68481F]) but can’t find it with this plugin, though other devices are visible . I also tried the other flutter bluetooth serial plugin but in my case I’ll be needing this functionality in my IOS app . Does any one has got any work around for this , it will be much appreciate . Thanks in advance .

Skalate commented 4 years ago

On Android devices, turn on GPS, and use all the functions in Flutter-blue. If not, phone can discover the device but cannot connect. Maybe you can turn on GPS. I haven't compiled the IOS program, maybe I can try it in a few days. I am a student studying automation, I don’t know much about android, but I have gained a lot of experience in the process of learning flutter. I am happy to share with you, I hope to keep in touch. 

 

李峦 掌上理工

联系我

 

------------------ 原始邮件 ------------------ 发件人: "Kushal Rathore"<notifications@github.com>; 发送时间: 2020年2月22日(星期六) 晚上6:37 收件人: "pauldemarco/flutter_blue"<flutter_blue@noreply.github.com>; 抄送: "李峦"<757122943@qq.com>; "Comment"<comment@noreply.github.com>; 主题: Re: [pauldemarco/flutter_blue] Cant find any devices while flutter blue scanning (#336)

HI Team ,
 I am also facing the same problem. My use case is I am trying to connect bluetooth scanner device (Socket 7XI[68481F]) but can’t find it with this plugin, though other devices are visible . I also tried the other flutter bluetooth serial plugin but in my case I’ll be needing this functionality in my IOS app . Does any one has got any work around for this , it will be much appreciate . Thanks in advance .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

KushalRathore09 commented 4 years ago

@Skalate thanks for reverting back , but unfortunately your solution didn't work for me . Have anyone got any solutions for this . Thanks in advance .

Skalate commented 4 years ago

I don't know how to solve your problem, maybe you can try to contact the author of flutter-blue. Or use mixed development, it will take you some days to study the swift language. 

李峦 掌上理工

联系我

 

------------------ 原始邮件 ------------------ 发件人: "Kushal Rathore"<notifications@github.com>; 发送时间: 2020年2月26日(星期三) 下午4:55 收件人: "pauldemarco/flutter_blue"<flutter_blue@noreply.github.com>; 抄送: "李峦"<757122943@qq.com>;"Mention"<mention@noreply.github.com>; 主题: Re: [pauldemarco/flutter_blue] Cant find any devices while flutter blue scanning (#336)

@Skalate thanks for reverting back , but unfortunately your solution didn't work for me . Have anyone got any solutions for this . Thanks in advance .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

GreeceNg commented 4 years ago

Hi I also have the same problem with trying to connect my arduino bluetooth using this example code. Is there any solution for this problem?

luissouza commented 4 years ago

@GreeceNg I have this problem. Some devices are not listed in this bluetooth plugin because they are different tecnologies. I had to change the plugin and now im using this: https://pub.dev/packages/blue_thermal_printer.

theali13 commented 4 years ago

Same Issue FlutterBluePlugin( 7582): mDevices size: 0

ride4sun commented 4 years ago

I have the same problem for me. I tried that 6 months ago with the same problem and I am surprised how little changed. @pauldemarco Hi Paul, do you have any input in this problem.

@luissouza I need basic write and read functionality with BLE. Would the package u use work fort that? Seems like this package works only for Android: https://pub.dev/packages/blue_thermal_printer.

Any alternative packages which are better maintained and work with ios would be highly appreciated. Any input?

theali13 commented 4 years ago

I have the same problem for me. I tried that 6 months ago with the same problem and I am surprised how little changed. @pauldemarco Hi Paul, do you have any input in this problem.

@luissouza I need basic write and read functionality with BLE. Would the package u use work fort that? Seems like this package works only for Android: https://pub.dev/packages/blue_thermal_printer.

Any alternative packages which are better maintained and work with ios would be highly appreciated. Any input?

That package didn't work for me either it, it doesn't connect

Skalate commented 4 years ago

Hello, I checked some information and sorted out the following possible solutions.  1. Try programming with Object-c. Create a new empty directory and use 'flutter create -i objc my-flutter-app' to create a new project. 

  1. Use a lower version of the API. 'use_frameworks! platform :ios, '9.0'' If none of the above solutions can be solved, I highly recommend you to learn IOS development, Mixed development seems to be the only way

李峦 掌上理工

联系我

 

------------------ 原始邮件 ------------------ 发件人: "theali13"<notifications@github.com>; 发送时间: 2020年3月25日(星期三) 上午6:37 收件人: "pauldemarco/flutter_blue"<flutter_blue@noreply.github.com>; 抄送: "李峦"<757122943@qq.com>;"Mention"<mention@noreply.github.com>; 主题: Re: [pauldemarco/flutter_blue] Cant find any devices while flutter blue scanning (#336)

I have the same problem for me. I tried that 6 months ago with the same problem and I am surprised how little changed. @pauldemarco Hi Paul, do you have any input in this problem.

@luissouza I need basic write and read functionality with BLE. Would the package u use work fort that? Seems like this package works only for Android: https://pub.dev/packages/blue_thermal_printer.

Any alternative packages which are better maintained and work with ios would be highly appreciated. Any input?

That package didn't work for me either it, it doesn't connect

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

ride4sun commented 4 years ago

Please try to use this branch. Defects got fixed on this branch which might fix ur problems. Keep track of this #145 to see if a new package get created to get better support.

use this in your yaml for now:

flutter_blue:
    git:
        url: https://github.com/boskokg/flutter_blue.git
        ref: 0.7.1
OmiWakode commented 4 years ago

I try to find the devices with de oficial example: https://github.com/pauldemarco/flutter_blue/tree/master/example

I have several devices (BLE) that should be listed, but they NEVER appear. What am i doing wrong? Please, help me!

All the devices are (BLE).

I also have the same issue. I don't know whats wrong

dirkbo commented 4 years ago

Same here. I should be able to see a lot of devices around me, but all i can see is my connected SPEN (Galaxy Note10), which i actually can't see when i open my phones bluetooth settings and scan for devices...

luissouza commented 4 years ago

@ride4sun

Im using now esc_pos_bluetooth plugin. This plugin (esc_pos_bluetooth) cant fin my device too. I get this plugin example, and i change a bit, in the connection code, like this.

 printerManager.selectPrinter(PrinterBluetooth(
        flutterBluetoothBasic.BluetoothDevice.fromDocument(printerName, printerAddress, 0,true)));

Hope it helps!

Akilesh30 commented 4 years ago

Hii I'm working on social distancing app I'm facing same issue couldn't get any mobile devices in scanresult

javiervalero31 commented 4 years ago

I Have the same problem ! When I start the scanning, the stream scanResults don't return anything... This feature is the most basic and don't work ! Any idea ?

luissouza commented 3 years ago

@javiervalero31, i think, is not return anything because all the devices that you are looking for are not BLE, and this plugin just show BLE devices.. Look in play store for BLE app, this app shows to you if your device is BLE (Bluetooh low energy).

nadjwarazali commented 3 years ago

I have the same problem before and all I did is turning on the location/ GPS and try to re-scan again and it works for my ESP32 BLE!

NongBritee commented 3 years ago

I'm facing same problem too. It works on many device to connect my thermal printer. e.g. iphone, ipad, redmi, huewei p30. But it's not working for my samsung note10lite and note10+. Any idea?

Detlev1 commented 3 years ago

@nadjwarazali Thank you it worked

afarre commented 3 years ago

Had the same problem with https://github.com/lupyuen/flutter-blue-sample example (based on pauldemarco's) and as others mentioned, turning on GPS (as well as bluetooth) solved this problem. I find it odd that you need location ON in order to find bluetooth devices. Anyone knows why?

alejo9719 commented 3 years ago

Google made it a requirement for using BLE in Android. https://www.polidea.com/blog/a-curious-relationship-android-ble-and-location/

http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Libre de virus. www.avg.com http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

El lun., 19 oct. 2020 a las 9:01, afarre (notifications@github.com) escribió:

Had the same problem with https://github.com/lupyuen/flutter-blue-sample example (based on pauldemarco's) and as others mentioned, turing on GPS (as well as bluetooth) solved this problem. I find it odd that you need location ON in order to find bluetooth devices. Anyone knows why?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/pauldemarco/flutter_blue/issues/336#issuecomment-712177646, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVNZAGU6AN5KBMBD2ID63LSLRBDPANCNFSM4IKMZMXA .

-- Javier Alejandro Velasco

ganeshlg commented 3 years ago

Turn on GPS it will work fine...!!!

BananaNeil commented 3 years ago

I was experiencing this issue when testing on a device with the --release flag.

Apparently there is an issue with the minification of flutter blue. There are two ways of working around the problem, as listed in this issue: https://github.com/pauldemarco/flutter_blue/issues/662

In android/app/build.gradle you can disable minifaction:

android {
    ...
    buildTypes {
        release {
            signingConfig signingConfigs.debug
            shrinkResources false
            minifyEnabled false
        }
    }

OR you can create a proguard rule that prevents flutter_blue from minimizing: In android/app/build.gradle:

android {
    ...
    buildTypes {
        release {
            signingConfig signingConfigs.debug
            minifyEnabled true
            useProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
        }
    }

and create a file at android/app/proguard-rules.pro with the following:

-keep class com.pauldemarco.flutter_blue.** { *; }
dprophete commented 3 years ago

Has anybody tried to connect to an epson TM-T88VI ? It just doesn't show up in the list. Tried to enable GPS and all but still can't detect it (the android/ios app provided by Epson does detect it though...)

FlynnDerek commented 3 years ago

Hi all, I'm also having this issue, the scan only returns two devices named 'gDevice-beacon' which are not connectable. I did make sure that the ESP32 was discovered on lightblue, and it shows up. I also enabled location and bluetooth scanning on the app. I also tried disabling minimizing with no luck. I'm just wondering if anyone else has something I could try?

AndyTanuC commented 3 years ago

Hi all, I'm also having this issue, the scan only returns two devices named 'gDevice-beacon' which are not connectable. I did make sure that the ESP32 was discovered on lightblue, and it shows up. I also enabled location and bluetooth scanning on the app. I also tried disabling minimizing with no luck. I'm just wondering if anyone else has something I could try?

Are you running your app on your emulator ? If yes, then it's to be expected, since the emulators are not supporting the bluetooth yet (cmiiw). I faced the same issue, but when I try to run it on my android phone, it works just fine.

FlynnDerek commented 3 years ago

Hey @AndyTanuC, you're right. I was using an emulator, but decided to buy a cheap android tablet and its working great now. Thanks for your help!

islom9797 commented 2 years ago

As anywone used this package after change o null safety? i Have same issue I tried so many types ,turn on location ,mifinify enablaed false,shrinkresourses false, but no reaction D/FlutterBluePlugin(20287): mDevices size: 0 @pauldemarco plase help. I tried all points which have there

islom9797 commented 2 years ago

at the moment i am using Galaxy s21 and Galaxy fold for test

DyaaElabasiry commented 2 years ago

i had the same problem and it was in the permissions

UthraGomatam commented 1 year ago

@DyaaElabasiry how did you resolve it? pls help

vytautas-pranskunas- commented 1 year ago

Any updates on this? Why this packages is so bad maitained?

AlphaRosh commented 1 year ago

hi there i tried all the above added proguard,disabled shrinkResources false minifyEnabled false and advices from others too , but the scan results dont show the devices which are active

RafCoder90 commented 1 year ago

hi there i tried all the above added proguard,disabled shrinkResources false minifyEnabled false and advices from others too , but the scan results dont show the devices which are active

Sto avendo lo stesso problema ma vedo che il dispositivo bluetooth non me lo trovano nemmeno altre app, ma se dal mio smartphone faccio una normale scansione lo trova

KattlerJoe commented 1 year ago

Got the same problem, turning in GPS solved my problem. I also got different bugs on different android versions, all solved by the GPS-thing. Does anyone have an idea why flutter_blue does correlate with the GPS settings? It has something to do with permissionshandling..

RafCoder90 commented 1 year ago

Is this enough to grant permission?

... I have noticed that several third party apps also cannot find the device

KattlerJoe commented 1 year ago

dunno, for my problem activating gps was the solution

Lokendra16 commented 1 year ago

Make sure that device Gps location is enable, if the Gps is disable then you won't be able to scan the device.

idobenamram commented 1 year ago

Looks like enabling GPS location for our app worked! We did not need to enable GPS when we built from a windows machine... it only happened when we started building and debugging on macOS. Very weird, I guess when building on mac it really cares about permissions. Anyways thanks guys

larsien commented 1 year ago

in my case, I added below permission then it worked I found this from changelog(https://pub.dev/packages/flutter_blue_plus/changelog#140)

<uses-permission android:name="android.permission.BLUETOOTH_SCAN"
  android:usesPermissionFlags="neverForLocation" />
larsien commented 1 year ago

oh my... in release mode built apk , it still not work (no scan results... ) only debug build apk work. how to solve this?