InputStream and OutputStream from EASession is not ready for use if accessory was connected when app is not launched

Hi everyone.

I have an iOS application for work with an MFi-certified device connected to the iPhone via USB-C. When I launch the app and attach the device, I can create an EASession and use the InputStream and OutputStream as usual. But if I attach the device before launching the app I can't use the InputStream and OutputStream, because the hasBytesAvailable and hasSpaceAvailable properties are always false. The NSStreamEventHasBytesAvailable and NSStreamEventHasSpaceAvailable events will never be triggered. After I re-attach the device, the streams open fine and I can interact with the device.

What can be wrong with the case of attaching the device before the app launches?

What can be wrong with the case of attaching the device before the app launches?

How does the accessory protocol side of this work? Does you app write to the accessory first or is the app expecting to receive data first? Depending on exactly how the accessory is implemented, it's possible that it's sending data when it first connects (before you app runs) and then failing to send data later (after your app launches). What happens if you write data to the accessory?

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

InputStream and OutputStream from EASession is not ready for use if accessory was connected when app is not launched
 
 
Q