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

[Bugs][Bluetooth] Post all Bluetooth Controller Bugs Here!! #1194

Closed
Langerz82 opened this issue Jun 3, 2023 · 266 comments
Closed

[Bugs][Bluetooth] Post all Bluetooth Controller Bugs Here!! #1194

Langerz82 opened this issue Jun 3, 2023 · 266 comments

Comments

@Langerz82
Copy link
Collaborator

Langerz82 commented Jun 3, 2023

Hello,
In an effort to de-clutter the bugs list, post all bugs related to Bluetooth Pairing here thank-you.

Fix for Bluetooth Controllers that cant connect:

  1. SSH into your device.
  2. Copy/paste the following commands one at a time:
cd /emuelec/scripts
wget https://raw.githubusercontent.com/EmuELEC/EmuELEC/d186c194d32f82937352384fcbe22bb79add0571/packages/sx05re/emuelec/bin/batocera/emuelec-bluetooth
chmod +x /emuelec/scripts/emuelec-bluetooth
  1. Reboot then when the ES Loading Splash occurs power on your Game controller.
  2. If that does not work, try in ES press start for Emuelec Settings >> Bluetooth and Controller Settings, Then find the pair Controller entry and select it, and power on your Game Controller.
  3. You may need to also need to at least 30 seconds has past then plug in the Game Controller with a cable to your device if it has one.
  4. Unplug and see if it pairs then.

edit:
If that does not work in SSH type:

emuelec-bluetooth

Power on your controller.
If it trusts but not connects you may need to plug in your Controller to your device.
If it does not work either, post the output of the emuelec-bluetooth command.

Full credits go to @ebeem (https://github.com/ebeem) Minor modifications by me.

ref: #1076 (comment)

@junm6802030
Copy link

patch works

s905x4+ Fake PS4 Controller

After the device is restarted, turn on the SHARE + PS button to pair successfully instantly.

God worked hard
Thank you so much

@ebeem
Copy link

ebeem commented Jun 7, 2023

@junm6802030 the advantage of pairing over just connecting is that you can auto connect later. Can you let us know if you're able to reconnect after you put your controller to sleep? Or in other words, if you pair using the script and get connected, then you disconnect the controller and try to connect it again, does that work without needing to pair again?
Also, do you have different controllers to test? And what's your current controller?

btw, emuelec-bluetooth is executed on boot

@Langerz82
Copy link
Collaborator Author

Langerz82 commented Jun 7, 2023

@ebeem In the first connect it looks like it's not dropping the pair properly in the forget function.
@ebeem in the forget function, try also adding before "bluetoothctl remove", "bluetoothctl untrust [MAC_ADDRESS]".
That should work.

@ebeem
Copy link

ebeem commented Jun 7, 2023

@Langerz82 can you explain more please? i am not sure if I can see the failure in forgetting.

I am checking on my phone screen so the output might not look great.

The first pairing attempt failed because the controller is probably already paired using some other script, the fact that a try again message was printed indicates an execution of the BluetoothCTL forget command.

The second attempt succeeded, which means that the device was successfully removed from trusted and paired devices and was paired again, if it wasn't the case it will not be able to pair and it will fail.

@Langerz82
Copy link
Collaborator Author

@ebeem In your script just after the device found you check for a pre-existing pair, and call forget, couldnt you just add the untrust() before forget() and it should pair the 1st time correctly?

See:

            if (
                not dev.connected
                and dev.rssi != 0
                and "input-" in dev.icon
                and len(dev.name) > 0
            ):
                print(
                    "found device {}, mac: {}, icon: {}, paired: {}".format(
                        dev.name, dev.mac, dev.icon, dev.paired
                    )
                )

                # handle if a device is trying to pair while it's already paired
                if dev.paired:
                    print("pairing a paired device {}".format(dev.name))
                    bt.untrust(dev)
                    bt.forget(dev)

Is that no good?

@junm6802030
Copy link

@ebeem
@Langerz82
My controller failed to wake up after reconnecting after sleep, because it is a fake PS4 controller. Before patching, I have been manually pairing through SHH, and how many pairings are needed, it often takes a minute or two to connect multiple times.

I have 2 handles, but both are of the same model, so it's not worth testing.

@Langerz82
Copy link
Collaborator Author

Langerz82 commented Jun 7, 2023

@ebeem hey man, the untrust probably does nothing, my bad. If a controller is listed as paired couldn't just directly call connect() ?

@junm6802030 - Woah that last output is strange, can you open up the file in /emuelec/scripts/emuelec-bluetooth find near the top:

DEBUG = False

change to:

DEBUG = True

Then save, close and repeat test?

@ebeem
Copy link

ebeem commented Jun 7, 2023

@Langerz82 that will work if it's only trusted I think. It's not gonna work if it's paired.

As far as I am concerned, there's no unpair command in bluetoothctl, but maybe they introduced a one recently, I am not sure.

But only issuing an untrust command will probably break the code and make pairing impossible if the device is already paired.

Applying untrust before forget will do nothing, because forget issues a remove command which will untrust and unpair.

@ebeem
Copy link

ebeem commented Jun 7, 2023

@Langerz82 regarding issuing a connect command, not a good idea because we want the controller to be able to issue that, not the device itself or bluetoothctl.

This code will only be executed by the user after all

@ebeem
Copy link

ebeem commented Jun 7, 2023

@junm6802030 your controller has 1 of the mac addresses not trusted for some reason.

Can you try this after pairing?
bluetoothctl trust 71:4B:F4:A4:B6:7E

After that put controller into sleep and try to reconnect

@Langerz82
Copy link
Collaborator Author

Langerz82 commented Jun 7, 2023

@junm6802030 Hey, can you remove that long output you added in this post: #1194 (comment)
and add it in a gist with the link, https://gist.github.com

Try downloading and using this script:
SSH in go to /emuelec/scripts then:

cd /emuelec/scripts
rm /emuelec/scripts/emuelec-bluetooth
wget https://gist.githubusercontent.com/Langerz82/41cef0d791181dc8bc74a6a463129a2d/raw/9e8509536060883647dc9cd587ea11f1841d278e/gistfile1.txt
mv gistfile1.txt emuelec-bluetooth
chmod +x /emuelec/scripts/emuelec-bluetooth

edit: shit hang on a sec re-run the commands, I've added a couple lines.
@junm6802030

@Langerz82
Copy link
Collaborator Author

@junm6802030 I'll do that again.
Open SSH and enter these commands:

cd /emuelec/scripts
rm /emuelec/scripts/emuelec-bluetooth
wget https://gist.githubusercontent.com/Langerz82/6838a6c44232902a47182658c55cc00f/raw/c3972b9e93bbe5ef7c1e3e46fb56eeb3e08c4e84/emuelec-bluetooth
chmod +x /emuelec/scripts/emuelec-bluetooth

Then reboot and re-test.

@junm6802030
Copy link

junm6802030 commented Jun 7, 2023

@junm6802030我会再做一次。 打开SSH并输入以下命令:

cd /emuelec/scripts
rm /emuelec/scripts/emuelec-bluetooth
wget https://gist.githubusercontent.com/Langerz82/6838a6c44232902a47182658c55cc00f/raw/c3972b9e93bbe5ef7c1e3e46fb56eeb3e08c4e84/emuelec-bluetooth
chmod +x /emuelec/scripts/emuelec-bluetooth

然后重新启动并重新测试。

I tested this and still can't wake up. Does the above one need to be tested?

@Langerz82
Copy link
Collaborator Author

Langerz82 commented Jun 7, 2023

@junm6802030 It's the same, can you post the output when calling the command from SSH?

@Langerz82
Copy link
Collaborator Author

@junm6802030 Try this:

cd /emuelec/scripts
rm /emuelec/scripts/emuelec-bluetooth
wget https://gist.githubusercontent.com/Langerz82/6838a6c44232902a47182658c55cc00f/raw/03cf812491bc99768c2e99a4bc7d381be6eeb698/emuelec-bluetooth
chmod +x /emuelec/scripts/emuelec-bluetooth

try and run in SSH and post output. It has a small change to help us debug.

@Langerz82
Copy link
Collaborator Author

Langerz82 commented Jun 7, 2023

@junm6802030 One more time, try this hope it works:

cd /emuelec/scripts
rm /emuelec/scripts/emuelec-bluetooth
wget https://gist.githubusercontent.com/Langerz82/6838a6c44232902a47182658c55cc00f/raw/404b5236052f46a5f87768705460102e72cec7ec/emuelec-bluetooth
chmod +x /emuelec/scripts/emuelec-bluetooth

try and run in SSH and post output. It has a small change to help us debug.

@junm6802030 I updated the script try and re-run the commands above, then run command emuelec-bluetooth.

@Langerz82
Copy link
Collaborator Author

@ebeem , @junm6802030
The problem with the controller waking up, is it's configuration of that controller does not allow waking to occur (wake_allowed=False). We would have to have a scan running in the background polling constantly to check for devices searching to connect again. unless there is another way, maybe ebeem knows a solution?

@ebeem
Copy link

ebeem commented Jun 7, 2023

@Langerz82
I am not sure if that will not introduce extra input lag, most likely it will.

The wake allowed should allow a device to wake the system from suspend/sleep. It should have nothing to do with auto connect.

@junm6802030
A friend of mine tested original ps4 controller and it worked, so the question is, does this generic controller support different modes? Some manufacturers support different modes, like xbox, ps, switch, etc. Is it the case for this controller of yours? Maybe that's why you get multiple devices.

If you have Android, Windows, or Linux, try to pair the controller and see if it can auto connect. If the problem is with the controller, then I don't think we should try to handle it here. However, if it works on one of the former OSes, then we should investigate more.

@junm6802030
Copy link

@Langerz82 I am not sure if that will not introduce extra input lag, most likely it will.

The wake allowed should allow a device to wake the system from suspend/sleep. It should have nothing to do with auto connect.

@junm6802030 A friend of mine tested original ps4 controller and it worked, so the question is, does this generic controller support different modes? Some manufacturers support different modes, like xbox, ps, switch, etc. Is it the case for this controller of yours? Maybe that's why you get multiple devices.

If you have Android, Windows, or Linux, try to pair the controller and see if it can auto connect. If the problem is with the controller, then I don't think we should try to handle it here. However, if it works on one of the former OSes, then we should investigate more.
@Langerz82 @ebeem
i think you are right
If there is a problem with the handle itself, it may not even support wake-up, then we will not be able to solve it.

@Langerz82
Copy link
Collaborator Author

Langerz82 commented Jun 7, 2023

Here is what I have so far:
https://gist.github.com/Langerz82/6838a6c44232902a47182658c55cc00f

It enables the script to enter a loop or just execute once, which will be needed in ES.
When the emuelecRunEmu.sh is called it will update a flag file in temp which basically makes the script silent.

syntax:
emuelec-bluetooth [SCAN_INTERVAL] [SCAN_TIME] [SCAN_LOOP] [SCAN_LOOP_INTERVAL]
emuelec-bluetooth 10 10 1 <-- should run the script only once.
emuelec-bluetooth 10 10 -1 30 <-- should run the loop once for every 30 seconds
emuelec-bluetooth 10 30 1 <-- run scan once, with 3 attempts at connecting devices.
Let me know what you think.

@ebeem
Copy link

ebeem commented Jun 7, 2023

@Langerz82
I already run the script on my machine whenever the user is not in game, I can share the script later if you need it, but I don't know if there are any drawbacks to this approach, to me it's working completely fine and I can pair anytime without using the menu

@Langerz82
Copy link
Collaborator Author

Yes please, I'll take a look when you are ready. I too can pair anytime with my generic PS3 controller. Not sure if we will need a polling scan mechanism to routinely scan. Latency isnt so important when using ES, but people will definitely be annoyed if it adds lag in-game ha.

@ebeem
Copy link

ebeem commented Jun 7, 2023

Scan will keep running forever if you don't pass a timeout. If the total scan time is -1 then timeout parameter should be dropped.
But you have to kill the scan once you're in game

@Langerz82
Copy link
Collaborator Author

Yes it's designed to always run while the device is on but sleep during a game and not scan.

@wang80919
Copy link

wang80919 commented Jul 11, 2023

@ebeem抱歉,我对开始的态度不好,虽然我没有拿起广告修复该错误,但也删除了我稍后要做的评论。 @wang80919我把你的改变也包括进来了,理论上逻辑上是一样的。
请参阅: https://gist.github.com/Langerz82/ba1842e5ceac62ed6c243a45c85a8468/revisions

Is there a new test package?

We do not need you to translate.

@junm6802030
Copy link

@junm6802030 see: https://gist.githubusercontent.com/Langerz82/ba1842e5ceac62ed6c243a45c85a8468/raw/a11b7ff58d4fb842104484dbfdb98003b1b29a94/emuelec-bluetooth

This version is not easy to use, the first pairing is extremely slow, it takes 5 seconds, and it takes 5 seconds to pair after restarting, which is not a good experience for me personally.

@Langerz82
Copy link
Collaborator Author

@junm6802030 I did not change any of the timings from @ebeem 's version. I don't think we can make it run any faster.

@ebeem
Copy link

ebeem commented Jul 12, 2023

@junm6802030 Terminal output is needed to spot the issue, my guess is the device is already paired. If that's the case and a pairing attempt is made, the script will forget the device so it can pair again.

@Langerz82 changing update interval to 1 makes more sense now, and this will improve the re-pairing after forget. However, 5 seconds for pairing isn't bad, because pairing is needed once per device and then you will only reconnect, not re-pair.

@Langerz82
Copy link
Collaborator Author

@ebeem would it speed it up though? since it relies on a notification to start the pairing process.

@ebeem
Copy link

ebeem commented Jul 12, 2023

@Langerz82
Yes, it will speed up mutli device pairing.
You can check for yourself by trying to re-pair an already paired device (pair twice).

You will notice that the scanning will restart after pairing a device (I made it behave that way because of a bluez bug). The scanning will resume based on the update interval, because it will be responsible for running the scan again with the bluetooth scanning and ingame check

If we get rid of this part, no one will be and to re-pair unless they restart the script or the device.

@junm6802030 are you talking about slowness in pairing or connecting? You should only pair once and then you will be able to reconnect later without pairing

@wang80919
Copy link

print("running scan on " + str(SCAN_TIME), flush = True)
所有的 print 都加上 , flush = True
虽然不能加快速度,但是看上去会好很多。

@Langerz82
Copy link
Collaborator Author

added 1sec update interval.
not sure what the flush is for but I added it.

My PS3 Controller re-connected fast and the scan doesnt seem to interfere with the sixaxis pairing.

see:
https://gist.github.com/Langerz82/ba1842e5ceac62ed6c243a45c85a8468/revisions

@Langerz82
Copy link
Collaborator Author

Langerz82 commented Jul 12, 2023

on update interval 1 my controller took awhile to connect after disconnecting the cable, update interval 2 it's much faster I'll test a bit more.

edit:
update interval 1 is fine for me works no problem.

@ebeem
Copy link

ebeem commented Jul 12, 2023

added 1sec update interval.
not sure what the flush is for but I added it.

My PS3 Controller re-connected fast and the scan doesnt seem to interfere with the sixaxis pairing.

see:
https://gist.github.com/Langerz82/ba1842e5ceac62ed6c243a45c85a8468/revisions

That's because you're not returning false on device discovered after pairing ps3 controller (please leave it that way if you're not noticing any re-pairing issues). In the generic bluetooth pairing block, false is returned after successful pairing, which tells the Bluetooth scanning process to terminate so another one is created.

So the bug is, after successfully pairing a device, you will stop receiving notifications for that specific device (unless you restart the scan or maybe there's another trick that I am not aware of).

@wang80919
Copy link

added 1sec update interval. not sure what the flush is for but I added it.
all of them.
not just first one.

@ebeem
Copy link

ebeem commented Jul 12, 2023

added 1sec update interval. not sure what the flush is for but I added it.
all of them.
not just first one.

If you don't like the default behaviour of python's prints (which you will want to do only if you want to log into a file I guess). Then just run the python script with -u parameter.

python -u file.py

I think you can also add this to the file header, but I haven't tested.

#!/usr/bin/python -u

@Langerz82
Copy link
Collaborator Author

@ebeem Will the buffered/unbuffered option affect the bluetooth notifications? If it doesn't I think it's not really needed as the command will run in the background when starting emuelec.

@ebeem
Copy link

ebeem commented Jul 12, 2023

@ebeem Will the buffered/unbuffered option affect the bluetooth notifications? If it doesn't I think it's not really needed as the command will run in the background when starting emuelec.

There should be no side effects, it's probably a good idea to flush, but better try to include the -u parameter in header first, that will be way cleaner if it works.

To test, just output the emuelec-bluetooth to a file and check if output the file receives prints immediately

@Langerz82
Copy link
Collaborator Author

see:
https://gist.github.com/Langerz82/ba1842e5ceac62ed6c243a45c85a8468/revisions

I think it makes the bluetooth notifications faster but I am not sure.

@Langerz82
Copy link
Collaborator Author

Langerz82 commented Jul 12, 2023

This header should make tty unbufffered:
https://gist.github.com/Langerz82/ba1842e5ceac62ed6c243a45c85a8468/revisions

I checked with "#!/usr/bin/python -u " it doesnt work unfortunately.

edit:
wait yes it does sorry, ill change it.

@junm6802030
Copy link

EMUELEC:~ # emuelec-bluetooth
running scan on 60
emustation is active now or no devices found, resuming scan
found device Wireless Controller, mac: 71:4B:F4:A4:B6:7E, icon: input-gaming, paired: False
connected device Wireless Controller
stopping thread
emustation is active now or no devices found, resuming scan
found device Wireless Controller, mac: C3:C2:08:A7:61:E1, icon: input-gaming, paired: False
connected device Wireless Controller
stopping thread
emustation is active now or no devices found, resuming scan
found device Wireless Controller, mac: 71:4B:F4:A4:B6:7E, icon: input-gaming, paired: True
forgot device Wireless Controller
found device Wireless Controller, mac: 71:4B:F4:A4:B6:7E, icon: input-gaming, paired: False
connected device Wireless Controller
stopping thread
EMUELEC:~ #

@Langerz82 @ebeem
It seems that the latest patch needs to be restarted twice. After the first restart, the pairing cannot be driven well. It is recommended to restart the pairing work again.

The log output by the new code is very concise, and the code seems to be very streamlined. After successfully pairing one handle, a new process is opened to pair another handle.

@natehsu
Copy link

natehsu commented Aug 22, 2023

Hello, In an effort to de-clutter the bugs list, post all bugs related to Bluetooth Pairing here thank-you.

Fix for Bluetooth Controllers that cant connect:

  1. SSH into your device.
  2. Copy/paste the following commands one at a time:
cd /emuelec/scripts
wget https://raw.githubusercontent.com/EmuELEC/EmuELEC/d186c194d32f82937352384fcbe22bb79add0571/packages/sx05re/emuelec/bin/batocera/emuelec-bluetooth
chmod +x /emuelec/scripts/emuelec-bluetooth
  1. Reboot then when the ES Loading Splash occurs power on your Game controller.
  2. If that does not work, try in ES press start for Emuelec Settings >> Bluetooth and Controller Settings, Then find the pair Controller entry and select it, and power on your Game Controller.
  3. You may need to also need to at least 30 seconds has past then plug in the Game Controller with a cable to your device if it has one.
  4. Unplug and see if it pairs then.

edit: If that does not work in SSH type:

emuelec-bluetooth

Power on your controller. If it trusts but not connects you may need to plug in your Controller to your device. If it does not work either, post the output of the emuelec-bluetooth command.

Full credits go to @ebeem (https://github.com/ebeem) Minor modifications by me.
ref: #1076 (comment)

Hi, I'm using Emuelec 4.5, along with the script for this version, but Bluetooth controller pairing still fails. Here are the system messages. My controller is an Xbox Series X controller. I'm not sure where the issue might be. Thx for help

EMUELEC:~ # emuelec-bluetooth
Scanning available devices for 60 seconds, with interval 15, please wait...
Starting scan 1, please wait...
detected device Xbox Wireless Controller, mac: 44:16:22:DC:C1:F8, icon: input-gaming, paired: False
found device Xbox Wireless Controller, mac: 44:16:22:DC:C1:F8, icon: input-gaming, paired: False
failed to pair Xbox Wireless Controller, try again
Starting scan 2, please wait...
Starting scan 3, please wait...
Starting scan 4, please wait...

bluetooth-agent.log:
2023-08-22 13:30:23,172 event for b'Xbox Wireless Controller' (b'44:16:22:DC:C1:F8', b'input-gaming')(paired=not paired, trusted=trusted, connected=disconnected)
2023-08-22 13:30:26,184 no bt_types file
2023-08-22 13:30:26,185 event for b'Xbox Wireless Controller' (b'44:16:22:DC:C1:F8', b'input-gaming')(paired=not paired, trusted=trusted, connected=connected)
2023-08-22 13:30:26,691 no bt_types file
2023-08-22 13:30:26,692 event for b'Xbox Wireless Controller' (b'44:16:22:DC:C1:F8', b'input-gaming')(paired=not paired, trusted=trusted, connected=connected)
2023-08-22 13:31:07,647 no bt_types file
2023-08-22 13:31:07,647 event for b'Xbox Wireless Controller' (b'44:16:22:DC:C1:F8', b'input-gaming')(paired=not paired, trusted=trusted, connected=connected)
2023-08-22 13:31:49,381 Skipping (property Connected changed to False)

@ebeem
Copy link

ebeem commented Aug 22, 2023

@natehsu this doesn't look like the latest script. Please check the comments or master branch's script to make sure it's not just an outdated script.

@Langerz82
Copy link
Collaborator Author

@natehsu
Copy link

natehsu commented Aug 22, 2023

@ebeem @Langerz82
Thank you for your reply. I redownloaded the latest [emuelec-bluetooth] and executed it multiple times. However, Bluetooth controller pairing still fails. Here are the system messages:

EMUELEC:~ # emuelec-bluetooth
running scan on 60
emustation is active now or no devices found, resuming scan
found device Xbox Wireless Controller, mac: 44:16:22:DC:C1:F8, icon: input-gaming, paired: False
emustation is active now or no devices found, resuming scan
emustation is active now or no devices found, resuming scan
emustation is active now or no devices found, resuming scan
emustation is active now or no devices found, resuming scan
emustation is active now or no devices found, resuming scan
emustation is active now or no devices found, resuming scan
emustation is active now or no devices found, resuming scan
emustation is active now or no devices found, resuming scan
emustation is active now or no devices found, resuming scan
emustation is active now or no devices found, resuming scan
emustation is active now or no devices found, resuming scan
emustation is active now or no devices found, resuming scan
emustation is active now or no devices found, resuming scan
emustation is active now or no devices found, resuming scan
emustation is active now or no devices found, resuming scan
emustation is active now or no devices found, resuming scan
emustation is active now or no devices found, resuming scan
emustation is active now or no devices found, resuming scan
emustation is active now or no devices found, resuming scan
forgot device Xbox Wireless Controller
EMUELEC:~ #

bluetooth-agent.log:
2023-08-22 16:13:39,948 Skipping device b'03:B0:55:BC:C0:44' (no type)
2023-08-22 16:13:40,327 no bt_types file
2023-08-22 16:13:40,328 Skipping device b'43:F6:F6:22:DC:32' (no type)
2023-08-22 16:13:40,330 no bt_types file
2023-08-22 16:13:40,331 Skipping device b'5D:4B:11:AA:59:C4' (no type)
2023-08-22 16:13:54,999 no bt_types file
2023-08-22 16:13:55,000 event for b'Xbox Wireless Controller' (b'44:16:22:DC:C1:F8', b'input-gaming')(paired=not paired, trusted=untrusted, connected=disconnected)
2023-08-22 16:13:55,387 no bt_types file
2023-08-22 16:13:55,388 Skipping device b'58:C4:B3:70:30:37' (no type)
2023-08-22 16:13:55,570 no bt_types file
2023-08-22 16:13:55,571 event for b'Xbox Wireless Controller' (b'44:16:22:DC:C1:F8', b'input-gaming')(paired=not paired, trusted=trusted, connected=disconnected)
2023-08-22 16:13:58,645 no bt_types file
2023-08-22 16:13:58,646 event for b'Xbox Wireless Controller' (b'44:16:22:DC:C1:F8', b'input-gaming')(paired=not paired, trusted=trusted, connected=connected)
2023-08-22 16:13:59,145 no bt_types file
2023-08-22 16:13:59,147 event for b'Xbox Wireless Controller' (b'44:16:22:DC:C1:F8', b'input-gaming')(paired=not paired, trusted=trusted, connected=connected)
2023-08-22 16:14:39,277 no bt_types file
2023-08-22 16:14:39,278 event for b'Xbox Wireless Controller' (b'44:16:22:DC:C1:F8', b'input-gaming')(paired=not paired, trusted=trusted, connected=connected)
2023-08-22 16:15:53,629 Skipping (property Connected changed to False)
2023-08-22 16:15:53,734 no bt_types file
2023-08-22 16:15:53,735 Skipping device b'31:A8:F1:D9:79:9C' (no type)
2023-08-22 16:15:53,740 no bt_types file
2023-08-22 16:15:53,741 Skipping device b'14:4F:D4:C2:CA:94' (no type)
2023-08-22 16:15:53,784 no bt_types file

@wang80919
Copy link

emuelec-bluetooth
这个文件 只会在 开机的时候,执行一次。
然后是 打开 EMUELEC 的 MENU
控制器管理里面选择 搜索蓝牙手柄
才会运行。
这是我希望的效果。
当我已经配对好。重新连接,是不需要运行这个脚本的。
emuelec-bluetoothV6.zip
这个版本用了很久,没发现问题。就是配对之后,还会继续搜索,总时长 90秒。
不知道大家觉得 90 秒是不是太长了?

@natehsu
Copy link

natehsu commented Aug 23, 2023

@wang80919 Thank you for sharing the information.

Sharing test information: Later I tried manually pairing the Bluetooth controller using bluetoothctl. Sometimes it succeeds, and other times it fails. When observing failures, I checked the log using "journalctl -f | egrep -i blue" and found the following information:

Aug 24 01:59:05 EMUELEC bluetoothd[3660]: src/device.c:load_gatt_db() No cache for 44:16:22:XX:XX:XX
Aug 24 01:59:05 EMUELEC kernel: Bluetooth: SMP security requested but not available
Aug 24 01:59:11 EMUELEC bluetoothd[3660]: src/device.c:load_gatt_db() No cache for 44:16:22:XX:XX:XX
Aug 24 01:59:11 EMUELEC kernel: Bluetooth: SMP security requested but not available
Aug 24 01:59:16 EMUELEC kernel: Bluetooth: SMP security requested but not available
Aug 24 01:59:18 EMUELEC kernel: Bluetooth: SMP security requested but not available

When the message "EMUELEC kernel: Bluetooth: SMP security requested but not available" appears, the pairing is unsuccessful. I'm not sure what's causing this issue.

@wang80919
Copy link

@wang80919 Thank you for sharing the information.

Sharing test information: Later I tried manually pairing the Bluetooth controller using bluetoothctl. Sometimes it succeeds, and other times it fails. When observing failures, I checked the log using "journalctl -f | egrep -i blue" and found the following information:

Aug 24 01:59:05 EMUELEC bluetoothd[3660]: src/device.c:load_gatt_db() No cache for 44:16:22:XX:XX:XX Aug 24 01:59:05 EMUELEC kernel: Bluetooth: SMP security requested but not available Aug 24 01:59:11 EMUELEC bluetoothd[3660]: src/device.c:load_gatt_db() No cache for 44:16:22:XX:XX:XX Aug 24 01:59:11 EMUELEC kernel: Bluetooth: SMP security requested but not available Aug 24 01:59:16 EMUELEC kernel: Bluetooth: SMP security requested but not available Aug 24 01:59:18 EMUELEC kernel: Bluetooth: SMP security requested but not available

When the message "EMUELEC kernel: Bluetooth: SMP security requested but not available" appears, the pairing is unsuccessful. I'm not sure what's causing this issue.

I do not knwon 2.

@CelviD
Copy link

CelviD commented Sep 10, 2023

Hello. I have followed the steps in this fix but it didnt work for me. Cant detect xbox one s controller, and Terios T3 controller too.
It says no new devices. im on Emuelec 4.6. Anyone can help?

@wang80919
Copy link

wang80919 commented Oct 28, 2023

一些 python 的版本。无法运行我的 V6 的脚本。
那么就发一个 V7 新脚本吧。
emuelec-bluetoothV7.zip

@jcc113
Copy link

jcc113 commented Oct 31, 2023

一些 python 的版本。无法运行我的 V6 的脚本。 那么就发一个 V7 新脚本吧。 emuelec-bluetoothV7.zip

Hello! I have emuelec 4.6 on x96 max plus ultra (sc2_s905x4_4g.dtb) and bluetooth does not see any devices on it. I've already tried all the methods. How can I fix it?

Here is the error emuelec-bluetoothV7.zip:

EMUELEC:~ # emuelec-bluetooth
running scan on 60
> bluetoothctl power on
No default controller available

> bluetoothctl agent on
> bluetoothctl discoverable on
No default controller available

> bluetoothctl pairable on
No default controller available

devices_count= 0
> bluetoothctl show
No default controller available

ES is active now, resuming scan
NotFoundTimes= 0
process scanned devices
<  No default controller available
devices_count= 0
> bluetoothctl show
No default controller available

NotFoundTimes= 1
process scanned devices
<  No default controller available
devices_count= 0
> bluetoothctl show
No default controller available

NotFoundTimes= 2
process scanned devices
<  No default controller available
No new device, stopping scan
ELAPSED_TIME= 15
TOTAL_ELAPSED_TIME= 15
Traceback (most recent call last):
  File "/emuelec/scripts/emuelec-bluetooth", line 429, in <module>
    BT_THREAD._stop()
  File "/usr/lib/python3.9/threading.py", line 1011, in _stop
AssertionError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/emuelec/scripts/emuelec-bluetooth", line 432, in <module>
    BT_THREAD.stop()
AttributeError: 'Thread' object has no attribute 'stop'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/emuelec/scripts/emuelec-bluetooth", line 434, in <module>
    BT_THREAD.terminate()
AttributeError: 'Thread' object has no attribute 'terminate'
● bluetooth.service - Bluetooth service
     Loaded: loaded (/usr/lib/systemd/system/bluetooth.service; enable; preset: disabled)
     Active: active (running) since Tue 2023-10-31 13:25:27; 14min ago
   Main PID: 3935 (bluetoothd)
     Status: "Running"
      Tasks: 1 (limit: 3699)
     Memory: 2.2M
     CGroup: /system.slice/bluetooth.service
             └─3935 /usr/lib/bluetooth/bluetoothd

Oct 31 13:25:13 EMUELEC systemd[1]: Starting bluetooth.service...
Oct 31 13:25:27 EMUELEC bluetoothd[3935]: Bluetooth daemon 5.65
Oct 31 13:25:27 EMUELEC systemd[1]: Started bluetooth.service.
Oct 31 13:25:27 EMUELEC bluetoothd[3935]: Starting SDP server
Oct 31 13:25:27 EMUELEC bluetoothd[3935]: profiles/network/bnep.c:bnep_init() kernel lacks bnep-protocol support
Oct 31 13:25:27 EMUELEC bluetoothd[3935]: src/plugin.c:plugin_init() System does not support network plugin
Oct 31 13:25:27 EMUELEC bluetoothd[3935]: Bluetooth management interface 1.14 initialized
EMUELEC:~ # rfkill list all
0: bt-dev: bluetooth
        Soft blocked: no
        Hard blocked: no

@Langerz82
Copy link
Collaborator Author

No default controller available

@jcc113 No default controller available <-- solve that issue first. Then if fixed it should work ok.

@Langerz82
Copy link
Collaborator Author

new bluetooth bug thread here:
#1277

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

8 participants