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

Turn off bluetooth once the launch handshake is complete #18

Merged
merged 1 commit into from
Dec 2, 2023

Conversation

nisargjhaveri
Copy link
Owner

Fix #17

@hkfuertes
Copy link
Contributor

I'm building and I will test this today... anyway poweroff powers off the bluetooth? We should also power it on if the TCP socket is disconnected or when we reset the usb gadget... I guess that the only time that the bluetooth should be disconnected (or off) is while the TCP connection is live.

I will test this pr today anyway,
Thankyou very much!

@nisargjhaveri
Copy link
Owner Author

We should also power it on if the TCP socket is disconnected or when we reset the usb gadget...

We do enable bluetooth as part of the connect call while reconnecting in case if some failure in the proxy. Though, as a side note, tcp failures are not handled very well so far. But it does reconnect well if the usb fails.
https://github.com/nisargjhaveri/AAWirelessDongle/blob/1552ae61391b51b78f0d2d8523cc784b657ec80a/aa_wireless_dongle/package/aawg/src/aawgd.cpp#L29

I guess that the only time that the bluetooth should be disconnected (or off) is while the TCP connection is live.

Yes, that's the idea. More precisely, the bluetooth will now only be turned on while trying to connect to a phone once the headunit sends start accessory request.

@@ -166,6 +167,8 @@ void AAWirelessProfile::NewConnection(DBus::Path path, std::shared_ptr<DBus::Fil

AAWirelessLauncher(fd->descriptor()).launch();
Logger::instance()->info("Bluetooth launch sequence completed\n");

BluetoothHandler::instance().powerOff();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please dismiss me if I'm in error... but how about disconnecting here: https://github.com/nisargjhaveri/AAWirelessDongle/blob/1552ae61391b51b78f0d2d8523cc784b657ec80a/aa_wireless_dongle/package/aawg/src/bluetoothProfiles.cpp#L63 that we still have the file descriptor?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, could you please explain some more. How would it make a difference?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nono, just thinking out loud, I don´t know if it would do a difference, of if it actually done here... but here that we still have the bluetooth device, we could just terminate any connection with it, instead of just powering off all bluetooth...

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right. I did try simply disconnecting the device instead of powering off. Though, seems like the device automatically reconnects the AA profile anyway, which triggers another "handshake".

We might be able to remove the AA profile and then disconnect the device if this is causing any issues, to prevent reconnect. Thought we can just power off, which can maybe also help free up the shared antenna for WiFi even more.

@gamelaster
Copy link

Hi folks! I began testing this firmware today (I will do until Friday, I still didn't tried BT calls yet), but what I immediately noticed, is trouble with pairing. Due to the fact that it disconnected the device after sending request to connect via RFCOMM failed, I couldn't connect again, so it took me few RPi resets to properly pair and successfully connect to the headunit.

The solution for this would be, that app checks if there is active proxy between phone and headunit, and if not, periodically try to request connection to phone, so even this fails, RPi will try to connect to phone and engage connection.

@gamelaster
Copy link

gamelaster commented Dec 2, 2023

Past few days, BT calls were rock solid, so I guess this solved my issue, and it's OK to merge. Great job folks!

@nisargjhaveri
Copy link
Owner Author

Thanks @gamelaster for testing this out!

Due to the fact that it disconnected the device after sending request to connect via RFCOMM failed, I couldn't connect again, so it took me few RPi resets to properly pair and successfully connect to the headunit.

Could you explain this more, is this new with these changes? We don't power off unless the AA "handshake" completes.

@gamelaster
Copy link

gamelaster commented Dec 2, 2023

Could you explain this more, is this new with these changes? We don't power off unless the AA "handshake" completes.

@nisargjhaveri Oh, sorry, I didn't checked out how exactly it works. Although, I just had quite issues after I updated the firmware, to pair it again, and actually trigger the connection mechanism, I needed to re-plug RPi like 3 times to get it working at all. Could be related to #23 , as if my connection dropped during session, only way to reconnect was to replug RPi.

Also, I don't think this behavior is caused by this PR, so I guess it's OK to merge it, and continue discussion in #23

@nisargjhaveri nisargjhaveri merged commit d6774f5 into main Dec 2, 2023
4 checks passed
@nisargjhaveri nisargjhaveri deleted the bluetooth_off_once_connected branch December 2, 2023 18:46
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

Successfully merging this pull request may close these issues.

Bluetooth still connected after "handshake"
3 participants