Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth State "Unknown" after Navigator.pop #30

Open
KatayR opened this issue Nov 15, 2023 · 7 comments
Open

Bluetooth State "Unknown" after Navigator.pop #30

KatayR opened this issue Nov 15, 2023 · 7 comments

Comments

@KatayR
Copy link

KatayR commented Nov 15, 2023

My app has a login page. After the login, I push your example connection page for now.

When I login for the first time, everything works fine. But if I logout and then use Navigator.pop or push, login again and come back to connection page, then bluetooth state gets stuck at "Unknown". Only fix is to restart the app.

Dispose etc doesnt work

@rohitsangwan01
Copy link
Owner

rohitsangwan01 commented Nov 15, 2023

@KatayR BluetoothState will update only if there is any change in BluetoothRaio ( on/off ) etc
but you can also call

WinBle.getBluetoothState().then((BleState state){
  // Here get BleState
});

WinBle.bleState.listen((BleState state) {
    // Set listener for further updates
});

@KatayR
Copy link
Author

KatayR commented Nov 15, 2023

@KatayR BluetoothState will update only if there is any change in BluetoothRaio ( on/off ) etc but you can also call

WinBle.getBluetoothState().then((BleState state){
  // Here get BleState
});

WinBle.bleState.listen((BleState state) {
    // Set listener for further updates
});

Somehow it doesnt get completed. Print state in here never prints:

  void getLatestBluetoothState() async {
    WinBle.getBluetoothState().then((BleState state) {
      print("new Bluetooth State : " + state.toString());
      setState(() {
        bleState = state;
      });
    });
  }

  @override
  void initState() {
    super.initState();
    getLatestBluetoothState();
...
...

@rohitsangwan01
Copy link
Owner

@KatayR is it completing for the first time, or it never worked for you ?

@KatayR
Copy link
Author

KatayR commented Nov 15, 2023

@KatayR is it completing for the first time, or it never worked for you ?

Never works

@rohitsangwan01
Copy link
Owner

@KatayR can you please try in example app

@KatayR
Copy link
Author

KatayR commented Nov 15, 2023

@KatayR can you please try in example app

It's already almost completely same as example app tho. I only renamed your MyApp widget in main.dart to ConnectionSetupPage widget and put a login page before it.

So main.dart > LoginPage > ConnectionSetupPage(your main.dart codes and a logout button)

@rohitsangwan01
Copy link
Owner

rohitsangwan01 commented Nov 16, 2023

@KatayR ok its hard to tell why your app is not getting bluetooth state, but you can try to toggle bluetooth on/off after running app to see if bleState listener getting any updates
Also enable logs to see if you are getting bluetooth updates in logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants