I'm new to Flutter and I'm working on a project that needs Bluetooth to connect to my hardware. To my knowledge, Flutter_Blue works like this:
scan()
, also hook a listener to listen for new devices. (Which will return ScanedDevice, then add it to my list.)await device.connect()
device.discoverServices()
for characteristics in service.characteristics
to get characteristics from that device.characteristic.read().listen((value){//do something with value});
And I kept failing at stage 2, which is scanning for devices.
I somehow can't find my Bluetooth_Speaker with scan()
, I tried using different scanning modes(Low latency, Low Energy, Balanced).
I can find other devices easily which is not mine(But they somehow don't have a name, all IDs are unique). I have tried using my friend's phone as a device for my app to scan, but still no result.
With my android Bluetooth settings page, I can find the Bluetooth speaker (also my friend's phone) in the scanning new devices page.
Please tell me what went wrong I'll be very thankful. Thank you.
Environment:
Compile method: flutter run
Learned lesson(s) after viewing the replies:
Bluetooth has two types
Bluetooth_Low_Energy(BLE) is a technique that offers lower energy consumption, with a trade-off of slower transmission speed. Classic devices can offer 24Mbps, where Low_Energy only offers 1Mbps.
These two types of Bluetooth cannot be connected to each other.
In this case, Flutter's Flutter_Blue library uses the Low_Energy service, and the Bluetooth speaker is used as a Classic device, That's why Flutter_Blue cannot scan/discover the speaker.