chipweinberger / flutter_blue_plus

Flutter plugin for connecting and communicationg with Bluetooth Low Energy devices, on Android, iOS, macOS
Other
791 stars 479 forks source link

[Help]: macOS 14: `BluetoothAdapterState.unavailable` every time but my bluetooth is enabled #706

Closed karansingla007 closed 11 months ago

karansingla007 commented 1 year ago

Requirements

Have you checked this problem on the example app?

No

FlutterBluePlus Version

1.29.6

Flutter Version

channel stable 3.13.9

What OS?

macOS

OS Version

macOS 14.1.1

Bluetooth Module

BLE

What is your problem?

FlutterBluePlus.adapterState.listen((state) {
      _adapterState = state;
      setState(() {});
    });

Getting BluetoothAdapterState.unavailable everytime. I am running in MacOs.

Logs

2023-11-28 11:31:30.725 aavaa_flutter[4496:1446362] [FBP-iOS] handleMethodCall: flutterHotRestart
2023-11-28 11:31:30.725 aavaa_flutter[4496:1446362] [FBP-iOS] disconnectAllDevices(flutterHotRestart)
2023-11-28 11:31:30.725 aavaa_flutter[4496:1446362] [FBP-iOS] connectedPeripherals: 0
flutter: [FBP] <setLogLevel> args: 5
2023-11-28 11:31:30.728 aavaa_flutter[4496:1446362] [FBP-iOS] handleMethodCall: setLogLevel
flutter: [FBP] <setLogLevel> result: true
flutter: [FBP] <getAdapterState> args: null
2023-11-28 11:31:31.743 aavaa_flutter[4496:1446362] [FBP-iOS] handleMethodCall: getAdapterState
flutter: [FBP] <getAdapterState> result: {adapter_state: 1}
chipweinberger commented 1 year ago

never seen this issue before.

it's normal for it to be unavailable breifly.

karansingla007 commented 1 year ago

@chipweinberger how can i solve this issue. I couldn't able to scan device.

chipweinberger commented 1 year ago

perhaps you need to call some other FBP method to get bluetooth to initialize?

karansingla007 commented 1 year ago

Which method, would you like to suggest?

chipweinberger commented 1 year ago

nevermind, i'm wrong. setLogLevel is good enough.

this seems like a macOS issue, not FBP issue

try restarting computer

karansingla007 commented 1 year ago

i am already doing this.

FlutterBluePlus.setLogLevel(LogLevel.verbose, color: true);
chipweinberger commented 1 year ago

try restarting computer

youre on macOS 14, this is a new version of macOS and it will have bugs

karansingla007 commented 1 year ago

Just did, Still the problem is same.

chipweinberger commented 1 year ago

make sure you've added permissions. see readme

maham commented 1 year ago

Our current workaround is to make sure to listen to FlutterBluePlus.adapterState before doing other calls. Not sure if this works for other cases.

chipweinberger commented 12 months ago

@maham the problem is that FlutterBluePlus.adapterState gets stuck on unavailable

@karansingla007 any updates?

thiruarasu16 commented 11 months ago

We need to give permission for that bluetooth access, for that open macos project in xcode-> Runners->Targets->Runner->Signing and capabilities ->App sandbox ->hardware -> enable the bluetooth(tick the check box).

Hope above steps will help you in resolving this issue.

chipweinberger commented 11 months ago

Thanks @thiruarasu16 , I've updated the README & Common Problems.