Closed mayanksuman closed 3 years ago
Important Note: The spotlight device is designed for only one active connection at a time. The Projecteur seem to not work when device is connected by both means (USB and Bluetooth). However, to correct it press any key on spotlight device. The bluetooth connection will automatically disconnect and Projecteur will be able to work again.
Hi @mayanksuman , thank you for your work 👍 - I am currently traveling this weekend - but will review and integrate via feature branch in the next days.
Hi @jahnf , all the comments have taken care of. I have used QTimer
instead of nanosleep
.
We are checking the response of ping in async manner. We are not putting a timer with timeout for this case. Rather, the response to all the HID commands are handled in onHIDDataAvailable
function in src/spotlight.cc, whenever it is available.
It is not necessary that device send information only on request, sometime like connecting device for charging or other cases, it sends the information on its own. Hence, I thought that instead of checking the response to each HID command, let the HID response come and process it when it is available.
Hi @mayanksuman
What Linux-Distro are you running? I encounter two problems with this on my Ubuntu 20.04 machines when using bluetooth with the Spotlight device.
The hidraw sub-device is not readable by the user - so only running as root will correctly establish a hidraw sub-device -> This might just be a solvable with small changes the udev rules file - I will investigate more into this
But more importantly: Even when I run Projecteur as root - everytime I try to send the vibrate command I get a "The device is not active. Activate it by pressing any button on device."
[2021-07-19T08:02:28.567][dbg][projecteur.HID] Write 1101001d00005d00000000000000000000000000 to /dev/hidraw3
[2021-07-19T08:02:28.567][dbg][projecteur.HID] Write 1101051d00000000000000000000000000000000 to /dev/hidraw3
[2021-07-19T08:02:29.108][dbg][projecteur.HID] Received 1101051d00000000000000000000000000000000 from /dev/hidraw3
[2021-07-19T08:02:48.765][inf][projecteur.HID] The device is not active. Activate it by pressing any button on device.
[2021-07-19T08:02:53.565][inf][projecteur.HID] The device is not active. Activate it by pressing any button on device.
[2021-07-19T08:02:56.415][inf][projecteur.HID] The device is not active. Activate it by pressing any button on device.
[2021-07-19T08:03:08.662][inf][projecteur.HID] The device is not active. Activate it by pressing any button on device.
As you collected a lot of experience with the device, what could be the reason for this?
Just for information, the Bluetooth device on my machine detected by Projecteur looks like this:
Projecteur 1.0-alpha.33; device scan
* Found 1 supported devices. (0 readable, 0 writable)
+++ name: 'SPOTLIGHT'
userName: 'Logitech Spotlight (Bluetooth)'
vendorId: 046d
productId: b503
phys: f8:e4:e3:01:27:e5
busType: Bluetooth
devices: /dev/input/event24, /dev/input/event23, /dev/input/event22, /dev/hidraw3
readable: false
writable: false
What Linux-Distro are you running?
I am using Debian Testing on my main machine.
In your device scan, some sub-device (most probably /dev/hidraw3) is not readable or writable. So, even if the device is sending a connection active packet ({0x11, 0x01, 0x04, ...}), the software (Projecteur) is not able to receive it and hence reports that the device is not active.
I think, this is a issue with udev rule. One more point, are you running a virtual machine?
I have not tested bluetooth connection on virtual machine, as my machine do not provide mean to pass bluetooth device to virtual machine.
Nope not a virtual machine and all the sub-devices are readable when running as root. I have the issue even when running as root. As you see in the log, data gets written to hidraw3 and also received, but when sending the vibrate command it results in this:
[2021-07-19T08:02:28.567][dbg][projecteur.HID] Write 1101001d00005d00000000000000000000000000 to /dev/hidraw3
[2021-07-19T08:02:28.567][dbg][projecteur.HID] Write 1101051d00000000000000000000000000000000 to /dev/hidraw3
[2021-07-19T08:02:29.108][dbg][projecteur.HID] Received 1101051d00000000000000000000000000000000 from /dev/hidraw3
[2021-07-19T08:02:48.765][inf][projecteur.HID] The device is not active. Activate it by pressing any button on device.
[2021-07-19T08:02:53.565][inf][projecteur.HID] The device is not active. Activate it by pressing any button on device.
Device scan as root:
Projecteur 1.0-alpha.33; device scan
* Found 1 supported devices. (1 readable, 1 writable)
+++ name: 'SPOTLIGHT'
userName: 'Logitech Spotlight (Bluetooth)'
vendorId: 046d
productId: b503
phys: f8:e4:e3:01:27:e5
busType: Bluetooth
devices: /dev/input/event22, /dev/input/event23, /dev/input/event24, /dev/hidraw3
readable: true
writable: true
Edit: added addtional udev rules, so that as a user all sub-devices are now readable - issue remains the same when running as a regular user. - Don't have too much time now to investigate further, but any idea that you have is appreciated - will investigate more later this week.
Hi @jahnf ,
My mistake. Device activation packet is only sent in case of USB connection. If device is connected on Bluetooth
it should be considered online all the time.
Please change the isOnline
function definition in device.h
to
bool isOnline() { return (m_details.busType == BusType::Bluetooth ||
m_details.hidProtocolVer > 0); };
You can directly merge #142 in your feature branch with this fix.
Thanks, works now - will review the battery PR within the next days.
Ok ...
Should I rebase battery PR to your feature/spotlight-hidraw-functionality
branch?
Yes that would be helpful - I'd like to do tests on the feature branch for multiple systems before finally merging to develop.
Ok ... I will rebase and push on that PR.
This commit enables hidraw interface on logitech spotlight connected via bluetooth. Three major changes are
With this code, device can vibrate (and support other functionality as being worked in #136 ) even if it is connected on bluetooth.
Note: To connect logitech spotlight using bluetooth, press top button and the last button till the led light starting flashing. The spotlight device can now be paired with computer.