Home > Enterprise >  Can't find my android phone with flutter_blue package
Can't find my android phone with flutter_blue package

Time:05-05

I'm using flutter_blue package which scans only for BLE devices. I want to send and receive data between two phones, say phone1 and phone2. Currently, my flutter application with flutter_blue package (app is based on official github example) is only installed on phone1 and when I run it it can not find my phone2 even though the bluetooth is turned on. (I can connect those phones with bluetooth using normal android settings).

My guess is that my phone uses classic bluetooth mode when bluetooth is turned on, so it can not be discoverd with flutter_blue. Btw, I checked and my phone2 (honor10) supports BLE. My question is how can I discover my phone using this package ? Should I install the app on both phones or are there any settings that I should do in phone2 to enable BLE ? So, as you can see my first goal is just to establish an bluetooth connection, and later on I'll deal with data transfer.

CodePudding user response:

A BLE connection usually consists of a central and a peripheral device where the central searches for peripherals and the peripheral advertises its presence.

In your example, your phone1 is central, and your phone2 is peripheral. But your phone2 is not advertising its presence using BLE (which is not compatible with Bluetooth classic). Enabling your Bluetooth is not enough, you need an App that allows your phone to act as a peripheral device.

Since you probably want to develop the app for phone1 first, you can solve your problem by using an existing app on phone2 to advertise a peripheral. There are multiple Apps that allow this, one is the BLE Peripheral Simulator;

  • Related