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

Muse 2 Disconnects after a period of time #184

Closed
Colton127 opened this issue Sep 19, 2022 · 1 comment · Fixed by #212
Closed

Muse 2 Disconnects after a period of time #184

Colton127 opened this issue Sep 19, 2022 · 1 comment · Fixed by #212

Comments

@Colton127
Copy link

I'm running Windows 11 and using the Bluetooth adapter onboard the Realtek RTL8852AE chipset with the Bleak backend. My Muse 2 connects properly and streams fine, but randomly disconnects after roughly 10 minutes (it appears a bit random.) I have tried ensuring the Muse is fully charged.

This is really interfering with my ability to collect data, as the random disconnects interrupts any experiment entirely.

I enable logging within Bleak using
set BLEAK_LOGGING=1

Upon disconnection, a simple notification occurs "Disconnecting from BLE device".

Any advice/suggestions would be most appreciated.

Thank you.

@narodnik
Copy link
Contributor

narodnik commented Apr 16, 2024

It's because of your IdleTimeout operating system bluetooth setting or similar. Here's a simple patch to fix the issue:

diff --git a/muselsl/record.py b/muselsl/record.py
index 30a41cb..d5fff8a 100644
--- a/muselsl/record.py
+++ b/muselsl/record.py
@@ -218,9 +218,14 @@ def record_direct(duration,
     t_init = time()
     print('Start recording at time t=%.3f' % t_init)
 
+    last_update = t_init
     while (time() - t_init) < duration:
         try:
             backends.sleep(1)
+
+            if time() - last_update > 60:
+                last_update = time()
+                muse.keep_alive()
         except KeyboardInterrupt:
             break
 

Alternatively just disable your bluetooth idle timeout setting completely. On Linux you may need UserspaceHID=true as well.

Check pull request #212

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 a pull request may close this issue.

2 participants