←back to thread

298 points croes | 1 comments | | HN request time: 0.001s | source
Show context
franky47 ◴[] No.45088822[source]
I own a Switch 1, and the other day I wanted to play on the train, but the battery was low. I figured "no problem, I can connect it to my laptop and let it charge off is battery".

Nope. The MacBook Pro started charging off the Switch instead.

replies(3): >>45088936 #>>45089070 #>>45089390 #
parhamn ◴[] No.45088936[source]
I've wondered how this works (and who wins).
replies(2): >>45088994 #>>45089013 #
scottapotamas ◴[] No.45088994[source]
For two DRP (dual role) devices connected to each other, I believe in a default case the one that happens to advertise as a source first just becomes one.

The standard allows for a role swap at any point while connected, and if that’s triggered will be dependent on the firmware/config on one or both ends.

There’s probably more nuance hiding in the real world hardware too.

replies(2): >>45089023 #>>45089443 #
unsnap_biceps ◴[] No.45089023[source]
According to https://superuser.com/a/1773195

> Any DRP port must have pull-down 5k1 resistors on CC wires (as a sink), AND 10-22-56k pull-ups (as provider), but not at the same time. The DRP then alternates the sink advertising (5k1 pull-downs) with pull-ups (source advertising) about 10 to 20 times per second.

> If another DRP is connected, they both will toggle their advertising until a correct (pull-up - pull-down) combination occurs. Then CC controller(s) will stop toggling, and the end that happens to be in provider mode will provide +5VSAFE VBUS. The process will end in one or other direction, which will happen at random (since frequencies of toggling are independent).

replies(1): >>45089396 #
franky47 ◴[] No.45089396[source]
A protocol designed on who wins an race condition? That's wild.
replies(3): >>45089606 #>>45090342 #>>45090354 #
1. crote ◴[] No.45090354[source]
It works surprisingly well in practice. The key thing to remember is that you rarely connect identical devices together.

A laptop and a power bank both support both modes, but the laptop will have a "prefer sink" policy and the power bank will have a "prefer source" policy. As long as you don't connect two laptops or two power banks, it'll work out just fine.

Moreover, it has an override mechanism in case you do connect two identical devices. If you do connect two laptops together for data transferring, the OS should be able to let the user override the power flow direction - or even disable charging altogether.