How to make my phone a bluetooth peripheral and get notified when other bluetooth devices are connected to it? (Flutter)

56 Views Asked by At

I'm developing a Flutter app working as a bluetooth peripheral using flutter_blue_peripheral. I'm able to make the app advertise and connectable. I used another cell phone to scan and connect to my app so I know the advertising part works. However, the connection only last for less than 30s then the device connected to it will be kicked out. Also, the app doesn't know that there is a device connected to it.

I've created a periodic function to check the isConnected value every 5 seconds, it always return false. It is my advertise setting

  final AdvertiseSetParameters advertiseSetParameters = AdvertiseSetParameters(
    scannable: true,
    connectable: true,
    txPowerLevel: txPowerHigh,
    includeTxPowerLevel: true,
  );

What is the correct way to make my phone a bluetooth peripheral?

0

There are 0 best solutions below