Balena sound audio stuttering and bluetooth constantly disconnecting and reconnecting

Sure! Do you want me to collect the logs from /var/log/journal/b993ce325b5f4aefa301d8b5e0e048ee after enabling AUDIO_LOG_LEVEL to DEBUG ?

One more question, how do I capture the running logs e.g. something like tail -f abc.log?

Hi Alok , my guess is that @tmigone would have meant for you to grab logs from the bluetooth and/or audio service containers so no need to get anything from the journal. You can probably just enable that AUDIO_LOG_LEVEL == DEBUG on the device and then from the device dashboard click the little download logs button at the top right of the logs window.

Thanks!
Added the log level to debug.

And here is the log downloaded from the dashboard.

Note - This log was collected after bluetooth would have connected and disconnected at least 10 times.

Thanks for the logs it looks odd that a bunch of the services keep restarting over and over. Can you run the diagnostics check on this device (you can find it on the left hand menu in our dashboard) and post the results here if there are any failures.

These were restarted because I changed the AUDIO_LOG_LEVEL == DEBUG and before that, I did restart it for some other reason. One thing I noticed is, while Bluetooth was getting connected/disconnected, I could not see anything changing in the dashboard log console.

Here is the output from “Device diagnostics”

Hey thanks for the logs. I don’t see anything really suspicious other than the services restarts, but that wouldn’t cause 10 connect/disconnect events. What timeframe are we talking about for those 10 times? Was that over a few minutes?

The fact that the bluetooth container logs nothing while the disconnects are happening makes me think of hardware issues. We can maybe look into dmesg logs to see if there is anything there. Can you provide that log? You’ll need to run dmesg on the hostOS. If you have additional hardware you can also try to test with it. For example, using a bluetooth dongle if you have one, or trying with a different Raspberry Pi?

Also, for posterity, the env var AUDIO_LOG_LEVEL was introduced in balenaSound version 3.0 so in your case it didn’t matter.

Thanks for the details. I have already tried it with another raspberry pi 4 and another SD card, nothing changed.

Connect and disconnect would have happened over a few mins. This can be easily seen in the journal log I posted earlier.

journal_b993ce325b5f4aefa301d8b5e0e048ee

Sep 22 18:24:54 2828aa0 bluetoothd[1543]: connect error: Connection timed out (110)
.
Sep 22 18:27:06 2828aa0 bluetoothd[1543]: connect error: Connection timed out (110)
.
Sep 22 18:30:06 2828aa0 bluetoothd[1543]: connect error: Connection timed out (110)
.
Sep 22 18:35:13 2828aa0 bluetoothd[1543]: connect error: Connection timed out (110)
.
.
Sep 22 18:37:08 2828aa0 bluetoothd[1543]: connect error: Connection timed out (110)

Here is the output from of dmesg

One more point I mentioned earlier, but I guess its worth mentioning again - Bluetooth works with NO issues when I am streaming music. As soon as I pause or stop the music, it starts getting disconnect/connect.

Just another idea to rule out wireless signal/noise/interference issues, can you try installing hcitool and check what the signal quality is like?

Also, I can see in the dmesg logs, that there are 74 bluetooth devices with the same mac A8:87:B3:31:64:9D. That doesn’t look right. Do you know what device this MAC is associated with?

Presumably that the Samsung phone you are pairing with the Pi. Can you try to reset the BT peering cache and pair the device only once?

Okay. Sure!

1 - For signal strength, how do I get the Bluetooth address?

2 - Regarding MAC address - As per the dashboard DC:A6:32:BF:11:CC is the MAC address. Not sure why it’s appearing twice.

3 - Yes, the device I am using most of the time is Samsung S10. Cleared the Bluetooth cache, still no impact.
I have tried it with a Macbook Pro and an iPhone XS and observed the same behavior.

One more point - While I was there checking “Device diagnostics”, I checked “Device health check” as well. I see 2 errors. Not sure if these can cause Bluetooth issue. Just wanted to highlight.

Okay. So I flashed another SD card with the same build; check_localdisk error is gone, however, I am still getting -

 Some networking issues detected: 
test_balena_registry: Could not communicate with  for authentication

Hi!!

1 - For signal strength, how do I get the Bluetooth address?

You can run hcitool dev and it’ll show the local Bluetooth device along with its address. In order to check a connection signal strength, run hcitool rssi <CONNECTED DEVICE MAC>

2 - Regarding MAC address - As per the dashboard DC:A6:32:BF:11:CC is the MAC address. Not sure why it’s appearing twice.

They are not the same (the last letter changes ;-)) This should be showing the MAC address of your ethernet and wifi adapters.

One more point - While I was there checking “Device diagnostics”, I checked “Device health check” as well. I see 2 errors. Not sure if these can cause Bluetooth issue. Just wanted to highlight.

The check_localdisk error was warning you that the SD card was starting to fail, so it was a good thing that you replaced it :). However, the check_networking error indicates that your network configuration is not meeting Balena apps requirements. Please make sure that your network setup is as this guide: Network Setup on balenaOS - Balena Documentation

Thanks kaisoz.

For signal strength, I can’t get it working …

root@eb67f67:~# hcitool rssi DC:A6:32:BF:11:CC
Not connected.
root@eb67f67:~# hcitool rssi DC:A6:32:BF:11:CE
Not connected.
root@eb67f67:~#

The check_localdisk error - can this impact Bluetooth? Also, not sure if I understood the instructions given on the URL. It says whitelist a list of domains but where? on my router, browser, or on my laptop?

Each of these should work with outward only (and inward once outward connection established) firewall settings. Additionally, the NTP ( 123) and DNS (53 ) ports may be blocked if a local NTP and DNS server are provided.

What does it mean, what I am supposed to do with this? These are probably too technical for me :frowning:

Hi,

The whitelisting is done with the hcitool as in hcitool lewladd <url>…done on the command line of the HostOS.

John

Okay. So I whitelisted it.

=============================================================
    Welcome to balenaOS
=============================================================
root@eb67f67:~# hcitool lewladd https://dashboard.balena-cloud.com/devices/eb67f67d4cb9b4a772301e214948ef9a/summary
root@eb67f67:~# 
root@eb67f67:~#

But I am still getting that error. More importantly, do you really think this error has anything to do with the Bluetooth issue I mentioned? I will let you guys decide on that but I think this debugging is going in another direction :slight_smile:

You could try moving the device around the room to see if any of the observed behaviours change. The other thing to try is to re-flash it and start from the beginning.