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

Error linking to light NEEWER-RGB660 #46

Closed
yodatak opened this issue Sep 4, 2022 · 14 comments
Closed

Error linking to light NEEWER-RGB660 #46

yodatak opened this issue Sep 4, 2022 · 14 comments

Comments

@yodatak
Copy link
Contributor

yodatak commented Sep 4, 2022

Hi thanks for your app , i cannot make it works with Fedora 36 with Python 3.10.6, python3-pyside2-1:5.15.2.1-4, bleak 0.16.0

Have you got any idea how to make it works ?
Thanks again !

yodatak@fedora  ~/Projets/NeewerLite-Python   main ±  pip3 install bleak
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: bleak in /home/yodatak/.local/lib/python3.10/site-packages (0.16.0)
Requirement already satisfied: async-timeout>=4.0.1 in /usr/lib/python3.10/site-packages (from bleak) (4.0.2)
Requirement already satisfied: typing-extensions>=4.2.0 in /home/yodatak/.local/lib/python3.10/site-packages (from bleak) (4.3.0)
Requirement already satisfied: dbus-next in /home/yodatak/.local/lib/python3.10/site-packages (from bleak) (0.2.3)

python3 NeewerLite-Python.py
/home/yodatak/Projets/NeewerLite-Python/NeewerLite-Python.py:2883: DeprecationWarning: There is no current event loop
loop = asyncio.get_event_loop()

         NeewerLite-Python ver. 0.12
             by Zach Glenwright

https://github.com/taburineagle/NeewerLite-Python <


/home/yodatak/Projets/NeewerLite-Python/NeewerLite-Python.py:3275: DeprecationWarning: There is no current event loop
loop = asyncio.get_event_loop() # get the current asyncio loop
QSocketNotifier: Can only be used with threads started with QThread
[01:48:48] - Searching for new lights
[01:48:56] - Background Thread Running
[01:48:58] - Searching for new lights
[01:49:03] - Found new light! [NEEWER-RGB660] MAC Address: FD:18:68:CD:42:20 RSSI: -79 dBm
[01:49:04] - Attempting to link to light [NEEWER-RGB660] MAC Address: FD:18:68:CD:42:20 (Attempt 1 of 6)
[01:49:14] - Error linking to light [NEEWER-RGB660] MAC Address: FD:18:68:CD:42:20

@taburineagle
Copy link
Owner

Interesting - it looks like something may have changed with Bleak since the version I wrote the program with, because of the DeprecationWarning. It actually looks like it's more of an issue with Python versions > 3.10, as I see other projects that use asyncio with the same error - I'll check more into this...

@taburineagle
Copy link
Owner

I think I have a lead on a fix for this - the verbiage seems to have changed since the Python version I'm using (3.8 - I need to upgrade 😅) - so I'll work on a fix for the DeprecationWarning error.

@taburineagle
Copy link
Owner

OK @yodatak - I've released a new version (0.12b) which should fix this issue - or at least creates the event loop in a more Python > 3.10 way, so it should fix the issue. I tested it on both Python 3.9 and 3.10.7 on Windows, Mac and Ubuntu and it worked on all of those setups, so it should theoretically also work on Fedora. Let me know if you have any issues!

@yodatak
Copy link
Contributor Author

yodatak commented Sep 11, 2022

Thanks i got this error now and i canot see the bluetooth device

 yodatak@fedora  ~/Projets/NeewerLite-Python   main  python3 NeewerLite-Python.py 
---------------------------------------------------------
             NeewerLite-Python ver. 0.12b
                 by Zach Glenwright
  > https://github.com/taburineagle/NeewerLite-Python <
---------------------------------------------------------
QSocketNotifier: Can only be used with threads started with QThread
[23:03:15] - Searching for new lights
Exception in thread workerThread:
Traceback (most recent call last):
  File "/usr/lib64/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/usr/lib64/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/home/yodatak/Projets/NeewerLite-Python/NeewerLite-Python.py", line 2591, in workerThread
    threadAction = _loop.run_until_complete(findDevices()) # add new lights to the main array
  File "/usr/lib64/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/yodatak/Projets/NeewerLite-Python/NeewerLite-Python.py", line 2138, in findDevices
    devices = await BleakScanner.discover() # scan all available Bluetooth devices nearby
  File "/home/yodatak/.local/lib/python3.10/site-packages/bleak/backends/scanner.py", line 117, in discover
    async with cls(**kwargs) as scanner:
  File "/home/yodatak/.local/lib/python3.10/site-packages/bleak/backends/scanner.py", line 97, in __aenter__
    await self.start()
  File "/home/yodatak/.local/lib/python3.10/site-packages/bleak/backends/bluezdbus/scanner.py", line 129, in start
    manager = await get_global_bluez_manager()
  File "/home/yodatak/.local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 783, in get_global_bluez_manager
    await instance.async_init()
  File "/home/yodatak/.local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 225, in async_init
    assert_reply(reply)
  File "/home/yodatak/.local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.freedesktop.DBus.Error.NameHasNoOwner] Could not activate remote peer: unit failed.

@yodatak
Copy link
Contributor Author

yodatak commented Sep 11, 2022

Or this error was because i don't have the bluetooth usb connected :
now i got this error
image

@yodatak
Copy link
Contributor Author

yodatak commented Sep 11, 2022

More try
image

@yodatak
Copy link
Contributor Author

yodatak commented Sep 11, 2022

I try to build it in a flatpak and i got the same problem if you are interested in testing the flatpak and publish the app in flathub don't hesitate i will made a PR but i'm not sure if its works because of my light that don't connect

@taburineagle
Copy link
Owner

I might take you up on that, although I don't know what flatpak is :) I need to do some research on that. I do see the light did manage to connect once in your "more testing" picture -

image

I'm not sure where the light physically is in relation to your PC, but it might be a weak connection from the Bluetooth to the light. I'd say if it's possible to, just to try, move the light closer to the PC and see if you get the same results.

I was going to say for your first post "are you sure Bluetooth is turned on?", but I see that it wasn't - ha, but... I'm confused what the QSocketNotifier error is referring to, I don't use QSocketNotifier in my program at all (I do use threading, but not specifically a QThread, Qt must be using the QSocketNotifier in the background - this one's also going to need some more research.) I did look the error up on Google and came up with a few other errors of the same type, also using Fedora, with both C++ and Python, so it may be how Fedora uses Qt.

@yodatak
Copy link
Contributor Author

yodatak commented Sep 12, 2022

I try closer same error for me.

Flatpak is a way to package a desktop application a universal way it can be install on all system with flatpak and published on the store https://flathub.org

@taburineagle
Copy link
Owner

Got you - that might be a good thing to look into! OK, I've downloaded Fedora myself and installed it into a Virtual Machine running on Oracle VirtualBox -

Fedora 36, Python 3.10.4, and these packages from pip, in a venv Python virtual machine:
PySide2-5.15.2.1-5.15.2-cp35.cp36.cp37.cp38.cp39.cp310-abi3-manylinux1_x86_64.whl
Shiboken2-5.15.2.1-5.15.2-cp35.cp36.cp37.cp38.cp39.cp310-abi3-manylinux1_x86_64.whl (part of PySide2)
Bleak-0.17.0-py3-none-any.whl

I do get the QSocketNotifier error on launching NeewerLite-Python (as well as an error that I'm not using Wayland - my Fedora installation uses Gnome instead apparently), but the program still seems to control the lights on my end without an issue -

Screenshot from 2022-09-12 19-31-53

I'm sorry you're having so many issues with it :( This other screenshot you sent yesterday also indicated that you did get a successful connection to the light in another instance, but it looks like it might not have kept that connection alive for some reason [??] -

image

@yodatak
Copy link
Contributor Author

yodatak commented Sep 14, 2022

Hello i just test with another computer it works i think its my bluetooth usb key that is not good
So i have the bug but its not your app maybe bleak or something ^^
I try to send you patched files in a PR to get you app in flathub store

@taburineagle
Copy link
Owner

Ah, excellent - it might be an older Bluetooth dongle that doesn't fully support BLE (Bluetooth Low Energy), but I'm not sure... thanks!

@yodatak
Copy link
Contributor Author

yodatak commented Sep 16, 2022

With
Bus 003 Device 023: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
sudo hciconfig hci0 lestates
Supported link layer states:
YES Non-connectable Advertising State
YES Scannable Advertising State
YES Connectable Advertising State
YES Directed Advertising State
YES Passive Scanning State
YES Active Scanning State
YES Initiating State/Connection State in Central Role
YES Connection State in the Peripheral Role
YES Non-connectable Advertising State and Passive Scanning State combination
YES Scannable Advertising State and Passive Scanning State combination
YES Connectable Advertising State and Passive Scanning State combination
YES Directed Advertising State and Passive Scanning State combination
YES Non-connectable Advertising State and Active Scanning State combination
YES Scannable Advertising State and Active Scanning State combination
YES Connectable Advertising State and Active Scanning State combination
YES Directed Advertising State and Active Scanning State combination
YES Non-connectable Advertising State and Initiating State combination
YES Scannable Advertising State and Initiating State combination
YES Non-connectable Advertising State and Central Role combination
YES Scannable Advertising State and Central Role combination
YES Non-connectable Advertising State and Peripheral Role combination
YES Scannable Advertising State and Peripheral Role combination
YES Passive Scanning State and Initiating State combination
YES Active Scanning State and Initiating State combination
YES Passive Scanning State and Central Role combination
YES Active Scanning State and Central Role combination
YES Passive Scanning State and Peripheral Role combination
YES Active Scanning State and Peripheral Role combination
YES Initiating State and Central Role combination/Central Role and Central Role combination

hciconfig -a

hci0: Type: Primary Bus: USB
BD Address: 00:1A:7D:DA:71:15 ACL MTU: 310:10 SCO MTU: 64:8
UP RUNNING PSCAN
RX bytes:747 acl:0 sco:0 events:55 errors:0
TX bytes:3197 acl:0 sco:0 commands:53 errors:0
Features: 0xff 0xff 0x8f 0xfe 0xdb 0xff 0x5b 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH HOLD SNIFF PARK
Link mode: PERIPHERAL ACCEPT
Name: 'BlueZ 5.65'
Class: 0x6c0104
Service Classes: Rendering, Capturing, Audio, Telephony
Device Class: Computer, Desktop workstation
HCI Version: 4.0 (0x6) Revision: 0x22bb
LMP Version: 4.0 (0x6) Subversion: 0x22bb
Manufacturer: Cambridge Silicon Radio (10)

So the bluetooth usb stick is only blueetooth 4.0

@yodatak yodatak mentioned this issue Sep 16, 2022
6 tasks
@taburineagle
Copy link
Owner

I'm going to try to check out all the Flatpak stuff in the next few days @yodatak - but I am closing this issue now, as it seems to be resolved with the other Bluetooth adapter - let me know if you have any other connection issues otherwise!

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