IntergatedCircuits / IPoverUSB

STM32 lwIP networking via USB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Detection of disconnection

FelixGruetzmacher opened this issue · comments

We are developing a USB device which, among other interfaces, provides ethernet via NCM with the help of your great library. It works beautifully.
However, we are running into a problem where the host sometimes decides to disconnect our device. We tested with other ethernet devices as well and saw the same disconnection behavior, so our device is not at fault (or at least shares this problem with others).
We are looking for a way (possibly a callback) to detect when the host disconnects from us. Unfortunately we cannot simply check VBUS as this pin is not handled by our main processor directly. Is there any way to ask how long ago the last transaction took place? We learned that not all transactions raise interrupts, so simply resetting a timer in the isr (as I ignorantly tried) won't do.
Any help is greatly appreciated.

First of all, great to hear that you are using this library, and feedback is always welcome! I'd also like to hear about the product once it makes it to the market :)

Regarding your question, I need some clarification before I can advise you on further steps. Namely I don't know what "the host disconnects our device" means in this context exactly.

  • Is the whole USB device disconnected, including no VBUS supply?
  • Or is the host sending a bus reset?
  • Or the disconnect is restricted to the NCM function inside the device?

It would also be a good idea to try to understand the reason why the host decides to do what it does, by looking at the OS logs. Which OSes produce this behavior?

You can also enable the SOF (start of frame) interrupts to see if they are also missing out when this disconnection happens, that would point to a power saving mode kicking in in the host OS. You can also use the device's Suspend and Resume callbacks to check this.