mirror of
https://github.com/liquidraver/ZephCore.git
synced 2026-09-01 20:09:17 +00:00
fix(usb): release the interface on VBUS removal
A device-side cable yank often skips the DTR=0 line-state change, so the companion stayed stuck on the USB interface and rejected every BLE connection until reboot. Treat USBD_MSG_VBUS_REMOVED as a DTR drop.
This commit is contained in:
@@ -134,6 +134,20 @@ static void usbd_msg_callback(struct usbd_context *const ctx,
|
||||
if (s_dtr_cb) {
|
||||
s_dtr_cb(dtr_now);
|
||||
}
|
||||
} else if (msg->type == USBD_MSG_VBUS_REMOVED) {
|
||||
/* Physical unplug — VBUS lost. On a device-side cable yank the
|
||||
* host often never sends a clean DTR=0 line-state change, so the
|
||||
* CONTROL_LINE_STATE release above won't fire and the companion
|
||||
* would stay stuck on the USB interface (rejecting every BLE
|
||||
* connection until reboot). Treat VBUS loss as a DTR drop so the
|
||||
* interface is handed back to BLE. */
|
||||
LOG_INF("CDC ACM: VBUS removed (device unplug)");
|
||||
if (s_dtr_active) {
|
||||
s_dtr_active = false;
|
||||
if (s_dtr_cb) {
|
||||
s_dtr_cb(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user