Let's say I have a USB OTG A-device that has negotiated a role swap via HNP, i.e. it is providing VBUS while acting in the device (non-host) role for data.
More commonly USB devices do not provide VBUS and therefore can detect that they have been disconnected from the host when VBUS disappears.
This is differentiated from a suspended state, where activity on the bus ceases but VBUS remains.
In the role swapped example, however, since the device is providing power it can't rely on the disappearance of VBUS to detect when the host is disconnected.
The only other option is to detect when activity on the bus ceases, but then how can this be differentiated from a suspended state?
I'm obviously missing something.
TIA
Best Answer
As Ale..chenski referenced in their comment, section 6.3 of the On-The-Go Supplement to the USB 2.0 Specification outlines the HNP Sequence of Events:
When a B-device acting as a host suspends the bus (step E), this indicates that it is finished acting as a host. A disconnect could also be interpreted as step E, however, the occurrence of (or lack of) step G allows the A-device to differentiate between a suspend and a disconnect.
A B-device acting as a host will only suspend the bus when it is finished acting as a host.