3 Replies Latest reply on Jun 28, 2018 7:53 AM by Steven Si

    ZQ520 takes > 5000 ms to close on iOS using Xamarin SDK

    Robert Blackwood

      Using LinkOS_Xamarin_SDK 1.1.75 to connect to a ZQ520 printer via Bluetooth (MFi) from an iPhone 8 plus running iOS 11.2.6, the print occurs quickly, but the full turnaround time of the call was taking multiple seconds (just over 5000 ms on average).  After throwing in some console logs of the elapsed times, it turns out that the vast majority of the time is being taken on calling Close() on the connection. ZSDK_API: MfiBtPrinterConnection Class Reference indicates there is a default 5000 ms timeout, and in iMZ220-MfiBtPrinterConnection::close is slow on IOS10 it is suggested that the developer override this setting, but that is using ZSDK_API developing natively against iOS (using Objective-C, it appeared).  I cannot find this setting exposed in the Xamarin SDK anywhere.  Can I override this?

        • Re: ZQ520 takes > 5000 ms to close on iOS using Xamarin SDK
          Steven Si

          Unlike the iOS version, unfortunately, there is no equivalent in Xamarin SDK to adjust the time to wait before closing the connection. This is something we could consider to add in the next revision of Xamarin SDK.

            • Re: ZQ520 takes > 5000 ms to close on iOS using Xamarin SDK
              Robert Blackwood

              Any suggestions on how to work around this? Is there a way to close the connection bypassing the SDK?  I've tried doing the close on a background thread to improve response time to the caller, but this seems to cause problems, as if I time it just right, printing rapidly in succession on printer discovery i get back an already-open connection that randomly closes in the middle of my operation.  Perhaps creating a new connection not through discovery would guarantee that it's a separate connection that won't randomly close on me?  Thoughts and/or code samples?

               

              I've also toyed with the idea of keeping the connection open, but I'm stuck on how it then ever gets closed.  The Best Practices For Printing documentation suggests the possibility of using "a timer to decide when to close the connection". Are there code samples anywhere for how this might be safely be accomplished without ending right back in the situation as before, where the connection randomly gets closed in the middle of a reuse?

                • Re: ZQ520 takes > 5000 ms to close on iOS using Xamarin SDK
                  Steven Si

                  In the current version of Link-OS SDK for Xamarin, the 5sec delay before closing the connection is a limitation and cannot be bypassed. However, this limitation shouldn’t be a huge issue if the implementation is right.

                   

                  I would avoid the scenario of open->print->close for each every print. If the current UI view has a print function, I would leave the connection open for all possible prints within that UI view, and only close the connection when leaving that UI view. This way we can avoid the possible conflict of trying to open a connection while the previous connection is not closed yet, etc.

                   

                  Currently, the Close() function is a blocking call, i.e. the calling thread will be blocked for 5sec. I would avoid using UI thread to call the Close() function to close the connection. I would delegate to a non-UI thread to call the Close(), at least the responsiveness of UI is not affected by the Close() function.

                   

                  We are sorry for this limitation, which we hope it gets resolved in the next release.