mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
USB hub: Change to connection interface so that applications can deal with external hubs
This commit is contained in:
@@ -141,25 +141,23 @@ static struct usbhost_connection_s *g_usbconn;
|
||||
#ifdef NSH_HAVEUSBHOST
|
||||
static int nsh_waiter(int argc, char *argv[])
|
||||
{
|
||||
bool connected = false;
|
||||
struct usbhost_hubport_s *hport;
|
||||
|
||||
syslog(LOG_INFO, "nsh_waiter: Running\n");
|
||||
for (;;)
|
||||
{
|
||||
/* Wait for the device to change state */
|
||||
|
||||
DEBUGVERIFY(CONN_WAIT(g_usbconn, &connected));
|
||||
|
||||
connected = !connected;
|
||||
syslog(LOG_INFO, "%s\n", connected ? "connected" : "disconnected");
|
||||
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
|
||||
syslog(LOG_INFO, "%s\n", hport->connected ? "connected" : "disconnected");
|
||||
|
||||
/* Did we just become connected? */
|
||||
|
||||
if (connected)
|
||||
if (hport->connected)
|
||||
{
|
||||
/* Yes.. enumerate the newly connected device */
|
||||
|
||||
(void)CONN_ENUMERATE(g_usbconn, 0);
|
||||
(void)CONN_ENUMERATE(g_usbconn, hport);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user