0

I'm currently working on a Flutter application that requires connecting to Bluetooth devices. I'm using the flutter_blue package to handle the connection.

My issue is that I'm unable to display the names of certain Bluetooth devices in the application. I've noticed that only the names of TVs are showing up, but not those of other devices. My main goal is to connect to ESP32 microcontrollers.

Here's what I've already tried:

-I checked that my phone could detect these Bluetooth devices outside of the application. -I consulted the documentation of the flutter_blue package and searched for similar issues on forums, but I didn't find a solution. -I verified the Bluetooth permissions in the AndroidManifest.xml file. -I expected that all detected Bluetooth devices would be listed with their names. However, some devices are not visible.

Do you have any suggestions for resolving this issue with displaying the names of Bluetooth devices in my Flutter application?

Thank you very much for your help!

2
  • Please provide enough code so others can better understand or reproduce the problem.
    – Community Bot
    Commented Sep 20, 2023 at 16:42
  • note that flutter_blue is deprecated. Use flutter_blue_plus Commented Sep 27, 2023 at 4:49

2 Answers 2

1

A Bluetooth LE device can, but does not have to, transmit its name in the Advertising PDU. If no name is available, the MAC address of the device can be used instead.

0

There are a few possibilities that you might need to reboot your device, you might need to put your device in "discovery mode", your phone may have already connected automatically, another app may have already connected to your phone may have already connected to your device Try looking through already connected devices:

Code Example:

//Search already connected devices, including devices
// connected to other apps
 List<BluetoothDevice> system = await 
 FlutterBluePlus.connectedSystemDevices;
 for (var d in system) {
 print('${r.device.localName} already connected to! ${r.device.remoteId}');
   if (d.localName == "myBleDevice") {
     await r.connect(); // must connect our app
     }
   }

. Maybe your scan filters are wrong. Try removing all scan filters, for withServices to work, your device must actively advertise the serviceUUIDs it supports.

Not the answer you're looking for? Browse other questions tagged or ask your own question.