-
Notifications
You must be signed in to change notification settings - Fork 0
Add HID battery interface, rework USB configuration (and remote wakeup) to run in c2usb thread #331
Conversation
also update battery level on BLE
6dde0a9
to
c67318c
Compare
The issue persists, and a regression has been introduced: after unpairing and pairing my UHK, now it sends HID reports via USB instead of BLE to my phone, even though the BLE connection seems to be established:
@benedekkupper Can you reproduce these issues? I want to avoid excessive testing. |
c67318c
to
a257229
Compare
I added a bunch more changes, please give it another go. |
I tested this PR by pairing and unpairing my Android phone and testing the mouse and keyboard interfaces on both Linux and Android. After 3 cycles, the mouse interface was broken both via USB and BLE. However, after resetting the right half, it endured more than 20 cycles, and it's still running well, and both the keyboard and mouse have been working. So it's not rock-stable yet, but we're getting very close. Should I merge this PR, and you'll open another one? |
a257229
to
3f3785f
Compare
I added another change, this should get it going, also please check the USB suspend/resume behavior. |
Pairing endured 30 pair-unpair cycles without hiccups, and I haven't tested any longer, so it seems rock stable. Regarding the suspend/resume behavior, the keyboard/mouse interfaces are always dead after I wake up my PC. On such occasions, I have to restart the right half. |
I think we can merge it then. Regarding the resume, what OS are you on? Is USB power saving enabled? What are the logs from the device? Can it recover if you unplug-replug the USB cable? |
I use Linux Mint, and I'm unsure whether power saving is enabled. I can dig into it if necessary. The Zephyr log doesn't contain anything upon suspend/resume, however, if I disconnect USB after resume, I get this log:
Then, when reconnecting USB, it works again. I'd rather merge this PR if this issue is fixed. |
Here's my last try at this. Honestly it seems that you manage to generate a continuous stream of reports out of your mouse interface, that leads to the last one being interrupted by the suspend, before being sent. This either means your hands are more nervous than should be, or that there is something fishy with the mouse movement calculation. |
Hmm, will look into that |
The keyboard and mouse interfaces are still dead after wake up until I reconnect USB. @kareltucek 1. Can you reproduce it? |
What is your evidence? I don't see such behavior.
Yes, if computer is waked via remote wakeup, then the device's keyboard and mouse interfaces are dead until USB reconnect. This also applies if we don't send any usb reports between the wakeup command and L0 callback signal.
(No.) |
Maybe one of you who can reproduce this issue can cross-check with a reference. Please switch to NCS 2.7.0, fetch hid-keyboard sample, and apply this patch on it: https://github.com/zephyrproject-rtos/zephyr/pull/79341/files and test it with a nordic devkit. |
The other thing to try in the firmware is in udc_mac.cpp , comment out the calls to |
@benedekkupper Commenting out the two occurrences of I'll test the keyboard sample as suggested soon. In the meantime, would you answer Karel?:
|
@benedekkupper The wake feature of the patched hid keyboard sample consistently works. How to proceed now? |
The next step is to try c2usb reference on zephyr with the nordic devkit. Please follow the readme here:
|
I followed the readme, and I can't build the project.
The major issue:
|
sorry about that, do a |
I flashed the hex file, and button 4 consistently wakes my PC. What should be the next step? |
Please also check that after wake, button 1 and led 1 are caps lock function, they should still be synced. If this also works, then we need to investigate how the USB_RemoteWakeup() is called, and make sure it's called exactly one time. I added printing for that on this branch now. |
d81df7b
to
d09b1ac
Compare
I flashed the hex. I could toggle Caps Lock via button 1. Then I put my PC to sleep. I woke it using button 1. Afterward, button 1 didn't toggle Caps Lock anymore. What's next? |
Is the behavior the same for both hex files? And if yes, could you test this part of the functionality on the zephyr sample as well? It also uses button 1 and led 1 for caps lock IIRC. |
Unlike the second sample, the first sample not only wakes the PC but Caps Lock always works. |
That leads me to conclude that the fix we need comes from zephyr upstream. Then I will pick up the NCS update to 2.7.0 task on the weekend, I have already found out about the board reorganization topic, so it shouldn't be that complicated. |
Great, thanks! Will you continue #213? I'm asking because it contains few changes, and it must be rebased, so you may want to start a new branch, in which case I'd close it. |
This MR is doing a few things together: