Keeping a USB Ethernet Connection Active While an iPhone Is Locked

Inquiry)

A Linux-based embedded device is connected to an iPhone using a USB-C cable.

The device operates as a USB device and presents a standard CDC-ECM Ethernet interface. The iPhone operates as the USB host.

When the iPhone screen is on:

  • 以太网接口被正确识别。
  • 分配IPv4和IPv6地址。
  • 互联网接入正常。

大约在 iPhone 被锁定 30 秒后,USB 连接进入暂停状态,以太网数据传输停止。

我们启用了USB远程唤醒。定期触发它有助于保持以太网接口的可用,当 iPhone 屏幕开启时网络会恢复。然而,屏幕关闭时以太网数据仍然无法保持活跃状态。

问题)

  1. 这在iOS上是正常的行为吗?
  2. 有没有支持的方法可以在 iPhone 锁定时保持 USB 以太网数据活跃?
  3. USB远程唤醒是否支持输入网络流量?
  4. 助理在恢复后是否需要发送任何CDC链接通知?
  5. 这需要支持MFi还是特定的iOS权限?

谢谢。

Answered by DTS Engineer in 904012022

The behaviour you’ve described doesn’t surprise me. I’ve not looked into the Ethernet side of this, but what you’re seeing closely matches the Wi-Fi behaviour. That is:

  • If you lock the screen, your app moves to the background and shortly thereafter gets suspended, meaning that it’s unable to perform networking.
  • If the device sleeps, the system disassociates from Wi-Fi.

I talk about these ideas in a lot more detail in the various posts linked to from Extra-ordinary Networking.

Does this require MFi support … ?

AFAIK MFi doesn’t have any specific provisions for Ethernet.

Does this … a specific iOS entitlement?

AFAIK there are no entitlements related to this.


What’s the actual problem you’re trying to solve here?

I suspect that you’re trying to communicate between your app and this Ethernet-based accessory. If that’s the case then the issue here isn’t really the Ethernet side of things, but rather your app. Apps in the background typically get suspended, and thus can’t do networking. In some circumstances it may be possible to stay running in the background, but those facilities all have limits. See iOS Background Execution Limits.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

When the iPhone screen is on:

  • The Ethernet interface is recognized correctly.
  • IPv4 and IPv6 addresses are assigned.
  • Internet access works normally.

Approximately 30 seconds after the iPhone is locked, the USB connection enters suspend and Ethernet data transmission stops.

We enabled USB Remote Wake. Triggering it periodically helps keep the Ethernet interface available, and the network recovers when the iPhone screen is turned on. However, Ethernet data still does not remain active while the screen is off.

Questions)

  1. Is this expected behavior on iOS?
  2. Is there a supported way to keep USB Ethernet data active while the iPhone is locked?
  3. Is USB Remote Wake supported for incoming network traffic?
  4. Does the accessory need to send any CDC link notification after resume?
  5. Does this require MFi support or a specific iOS entitlement?

Thank you.

The behaviour you’ve described doesn’t surprise me. I’ve not looked into the Ethernet side of this, but what you’re seeing closely matches the Wi-Fi behaviour. That is:

  • If you lock the screen, your app moves to the background and shortly thereafter gets suspended, meaning that it’s unable to perform networking.
  • If the device sleeps, the system disassociates from Wi-Fi.

I talk about these ideas in a lot more detail in the various posts linked to from Extra-ordinary Networking.

Does this require MFi support … ?

AFAIK MFi doesn’t have any specific provisions for Ethernet.

Does this … a specific iOS entitlement?

AFAIK there are no entitlements related to this.


What’s the actual problem you’re trying to solve here?

I suspect that you’re trying to communicate between your app and this Ethernet-based accessory. If that’s the case then the issue here isn’t really the Ethernet side of things, but rather your app. Apps in the background typically get suspended, and thus can’t do networking. In some circumstances it may be possible to stay running in the background, but those facilities all have limits. See iOS Background Execution Limits.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

no app is involved

OK, then I’m a bit confused. If you have no code running on the device, why does it matter than iOS is shutting down the Ethernet when it sleeps? Who are you trying to communicate with?

ps It’s better to reply as a reply, rather than in the comments; see Quinn’s Top Ten DevForums Tips for this and other titbits.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

The iPhone has no Wi-Fi or cellular data connection. This USB Ethernet accessory is its only Internet connection. No custom app is involved. Once the screen is locked, iOS suspends the Ethernet connection and the iPhone becomes completely offline, so it cannot receive app notifications or other Internet data. Is this expected behavior, and is there a supported way to keep the only active network interface available while the iPhone is locked?

it cannot receive app notifications

OK, that’s a valid use case.

For Wi-Fi, an iOS device with WWAN will shut down the Wi-Fi interface to save power, relying on WWAN for push notifications. OTOH, if the device doesn’t have WWAN, it’ll attempt to stay associated with Wi-Fi for these admins tasks.

I would expect this to work the same way on Ethernet, but I must admit that I’ve never tested this. Is this problem tied to your accessory? Or do you see the same issue if you use a generic off-the-shelf USB Ethernet adaptor?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Keeping a USB Ethernet Connection Active While an iPhone Is Locked
 
 
Q