iWatch network connectivity without iPhone

Hi,
I have an iOS/watchOS app that talks to an external device (a camera) on a proprietary tcp protocol via Network.framework.

With the latest version we have migrated communications to the watch so that the Watch talks to the camera directly (previously it did through the watch) - and I was hoping that we could get to a state where the iOS app is only required for configuration of the connection (logon info etc), which is much easier done on iOS.

So far everything works great - except that the iWatch looses Wifi connectivity as soon as the iPhone is out of range or joins another network.

I have configured the iWatch to join the cameras network - but still, as soon as the phone looses the network the connection is gone.

The idea really is to enable the user to work with the camera hands free with no need to use the phone.

The control center indicates that I am connected to Wifi, but Network.framework does not seem to connect.

Is there anything I need to configure on the tcp connection in Network.framework to have it talk to the device directly without checking the phone? Or is an independent connection of the iWatch to a network and tcp connection not possible (I thought with stand alone watch app this should work?)

As always - thanks for any hints or information!
Best,
Michael


Addition:
When I disable Wifi on the phone the debug output I get on the nwconnection is:
Connection Waiting! Optional([C6 192.168.153.1:5055 tcp, indefinite, no cellular, prefer companion, path unsatisfied (Path was denied by NECP policy), interface: ipsec1, ipv4, ipv6]) error:POSIXErrorCode: Network is down

I haven't seen the "prefer companion" part before - I guess this is my problem. Is there any configuration option for this part on the connection? Apart from this everything works as expected.


Regarding:

on a proprietary tcp protocol via Network.framework.
With the latest version we have migrated communications to the watch so that the Watch talks to the camera directly (previously it did through the watch)

Did you mean to say in the above statement that you have a TCP connection through Network Framework that used to run through the iOS device but now your have migrated it to watchOS only?

Regarding:

The idea really is to enable the user to work with the camera hands free with no need to use the phone.
The control center indicates that I am connected to Wifi, but Network.framework does not seem to connect.
Or is an independent connection of the iWatch to a network and tcp connection not possible (I thought with stand alone watch app this should work?)

I do want to mention the Low-Level Networking on watchOS post for this specific use case. As far as I know this has not changed.


Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
Hi Matt,
previously I had another layer using WatchCommunication in-between the watch and the iPhone - which was cumbersome and complicated. Now I migrated to using my protocol adapter (which is using network.framework and Combine) directly on the watch which not only enhanced performance but also drastically reduced the code size and increased development speed.

It seems since I disconnect when I background the app (the network protocol is binary and super low overhead and reconnect is quick) everything works amazingly well. The only problem I had was cached endpoints, which apparently don't seem to work. My only problem is that I cannot get rid of the phone in the network, which would be a huge benefit. The way it is you always need to have the phone close by and connected to the Wifi of the camera.

Everybody is actually quite blown away by the iWatch becoming a low profile interface - it turns into an indispensable professional tool which a lot of my customers don't want to miss...

But I recon the 'prefer companion' option on the nwconnection is fixed in iWatch - at least I did not find it anywhere in the header files.

  • michael

I cannot get rid of the phone in the network, which would be a huge benefit. The way it
is you always need to have the phone close by and connected to the Wifi of the camera.

Yes, this is the path here due to the low level network API constraints I mentioned on the previous post for watchOS only networking.

When I disable Wifi on the phone the debug output I get on the nwconnection is:
Connection Waiting! Optional([C6 192.168.153.1:5055 tcp, indefinite, no cellular, prefer
companion, path unsatisfied (Path was denied by NECP policy), interface: ipsec1, ipv4,
ipv6]) error:POSIXErrorCode: Network is down

Right. Notice the IP for your NWConnection: (192.168.153.1:5055). This is a local network address and you will only be able to reach this on a local network. That is why when you disable Wi-Fi, that I am assuming it is the Wi-Fi network being broadcasted from your Camera, your connection goes down.

Also note that "Connection Waiting," and "error:POSIXErrorCode: Network is down" errors are associated with iOS 14 Local Network Privacy Errors, so keep an eye on that from your iOS device.

For more on this, Quinn has an awesome FAQ section on Local Network Privacy here.


Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
iWatch network connectivity without iPhone
 
 
Q