-
Notifications
You must be signed in to change notification settings - Fork 1
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
Controller lags in relay mode when multiple devices connected to switch via bluetooth #1
Comments
Ok, so it seems that we regularly receive mode change events from the pro controller, and then once we connect a controller to the switch we get a few new events, but this time from the switch. This makes sense. Legend:
The first cluster of switch events are from me removing one joycon, and second is from removing the other joycon. I believe the most important ones are the max slots change events we receive from the switch. In order from top to bottom, the max slots changed values were 5, 5, 1, 5 This is when I smacked both joycons into the switch at the same time, probably wouldve been better to just do them one at a time but hey. Again we see the max slots changed events. In order from top to bottom, the max slots changed values were 1, 5, 1, 5 I'll be honest I don't know what these max slot values mean. HCI Events I believe we should forward from pro controller to switch
HCI Events I believe we should forward from switch to pro controller
|
Also I want to do some graphing of the time between each received packet and each sent packet within this log. I want to figure out if the controller is sending the packets badly or if the switch isn't letting us write all the packets we want as fast. My assumption is the later, which would explain the pauses and then sudden sending of movement packets which make the lag happen. I assume slots would in some way refer to slots that the switch is going to hold for packets? Maybe when more than one controller is connected, the switch tells the other controllers to slow down their polling rate to let the switch be able to handle everything?? |
Ok things I've learned about bluetooth. Radio -> Baseband -> LMP -> HCI -> L2CAP -> HID I am opening up sockets in the l2cap layer to forward data from controller to switch and from switch to controller. This works for the most part. When a second controller is connected via bluetooth to the switch, it sends out a request to change the max slots on the LMP layer to tell the bluetooth controllers to slow down so that everyone has enough room. That data also ripples an event into the HCI layer. Note the request is sent in LMP but you can read an event in HCI and LMP. That event is never sent over to the controller, because I'm only reading L2CAP, so the controller never slows down and then we lag. I need access to either HCI or LMP for reading, but I definitely need access to LMP for writing. Bluez makes reading HCI stuff easy, but no clue how hard it will be to rw LMP stuff. |
A lot of that info was found from this site https://www.amd.e-technik.uni-rostock.de/ma/gol/lectures/wirlec/bluetooth_info/radio.html |
Hi JuanPotato, I used tcpdump to sniff the bluetooth conversation. Then I used Matplotlib to visualize results. I just want to share my results with you.
I am sure it is not solvable only by slowing down the send frequency. Maybe the incoming message is not a handshake but a request for status massage (mentioned by @dekuNukem)? So the controller only need to send the status when he is asked for it? |
Hi, thank you so much for contributing to this! I have a few questions, the first being: How did you find this repo? (EDIT: Just realized you were the person who opened mart1nro/joycontrol#31, Got it!) Also, pairing is a little bad right now due to the fact that we dont flush out all the old packets before connecting to the switch. When the pro controller first connects to the pc, it sends small packets, presumably with bare minimum information for using it as a hid controller. It sends this every 15ms. These pile up very quickly between the time the pro controller connects, and the switch connects, so pairing is not very good while it catches up and floods the switch with old packets. I need to fix that. So if you have data from within the first ten seconds or so of connecting, its probably misleading. With regards to the first graph, I haven't graphed anything yet, but just looking at my wireshark capture, I don't have a message from the switch after three packets from the controller. Second graph, was the second controller already connected? When was it connected? Fourth graph and Fifth graph, I am generally not sure how to interpret these graphs. Sixth graph, how did you change the message sending frequency to 1hz? Thanks for joining in on my wild journey to try and figure out whats going on. I need to look more into what exactly the max slots changed event is changing. |
This comes right up in my mind, maybe it's important. I just use the dump from tcpdump for the plots. Maybe some of the incoming packages are not from the switch. Maybe they are just bluetooth protocol garbage and should be ignored? Not sure on this.. |
Ok, I've done some more research (you can read my stuff in #2 for what I found) and once I implement what I talked about there I will see if that fixes the issue. Those graphs were very interesting. |
See mart1nro/joycontrol#31
I am looking into how to forward HCI_EVT packets that we receive to the controller. Obviously not all of them because some are responsible for negotiating the encryption keys.
The text was updated successfully, but these errors were encountered: