15 Replies Latest reply on Jan 18, 2018 1:25 PM by Nicola Lazzara

    iMZ320 in iOS:Sometimes getCurrentStatus shows ErrorCode=7

    Molay Ash

      Hi,

      We are trying to retrive printer current status inside a timer in iOS but sometimes we are receiving ErrorCode=7 .

       

      We have done following:

       

      1) First connecting the printer as shown in below sample code and it was successful.

       

                                         id<ZebraPrinterConnection, NSObject> connection; //It's a global variable

                      connection = nil;

                      connection = [[MfiBtPrinterConnection alloc] initWithSerialNumber:printerSerialNumber];

                      [((MfiBtPrinterConnection*)connection) setTimeToWaitAfterWriteInMilliseconds:60];

                      NSError *error = nil;

                      BOOL didOpen = [connection open];

                      if (didOpen) {

                          zebraPrinter = [ZebraPrinterFactory getInstance:connection error:&error];

                          if(error != nil) {

                              return;

                          }

                      }

       

      2) Then inside a timer, we are checking printer status as shown in below code sample:

       

                       id<ZebraPrinter, NSObject> zebraPrinter;  //It's a global variable

              zebraPrinter = [ZebraPrinterFactory getInstance:connection error:&error];

              if(connection.isConnected)

              {

                  PrinterStatus *status = [zebraPrinter getCurrentStatus:&error];

                  if (error) {

                      //Here SOMETIMES we are getting ErrorCode=7

                      Error Domain=ZSDK_API_ERROR_DOMAIN Code=7 "Malformed status response - unable to      determine printer status" UserInfo={NSLocalizedDescription=Malformed status response - unable to determine printer status}

                  }

              }

       

      Please note:

       

      - We are using latest zebra sdk (V1.5.1049)

      - Printer Model: ZEBRA iMZ320

      - iOS version 11.2.1

      - We are NOT getting this error very frequently. But the error is there.

       

      We have spend lots of time to find the exact reason (also sequence to re-prouce) of this error. But unable to find any proper solution.

      Could you please let us know is there anything we are missing?

       

      In advance thanks,

      Molay

        • Re: iMZ320 in iOS:Sometimes getCurrentStatus shows ErrorCode=7
          Steven Si

          When "Malformed status response" error happens from getCurrentStatus:, it is usually due to two reasons: 1) the timeout from the Bluetooth stack, or 2) the corrupted status data received. When this happens, we can retry the getCurrentStatus:. Usually, it would succeed in the second time. There is no harm to try the status call multiple times. Besides the retry, we can also increase the wait time on the Bluetooth connection after read. The default timeout is set to 10ms. We can increase it to 20ms or 30ms to see if this resolves the "Malformed status response" error.

          [connection setTimeToWaitAfterReadInMilliseconds:timeout];
          

          There could be a variety of reasons causing the timeout, such as high priority tasks in background or high priority threads in the current application somehow slowing down the Bluetooth stack. As you described that this error doesn't happen frequently, it sounds a timeout in a specific circumstance. Let's know if changing the timeout would prevent it from happening.

            • Re: iMZ320 in iOS:Sometimes getCurrentStatus shows ErrorCode=7
              Molay Ash

              Hi Steven,

              Thank you for your reply.

              I have been trying with your suggested solution in two different ways:

               

              1) Adding setTimeToWaitAfterReadInMilliseconds

               

                                                id<ZebraPrinterConnection, NSObject> connection; //It's a global variable

                              connection = nil;

                              connection = [[MfiBtPrinterConnection alloc] initWithSerialNumber:printerSerialNumber];

                              [((MfiBtPrinterConnection*)connection) setTimeToWaitAfterReadInMilliseconds:60];  //I have tried with 20...30...40..            

                              [((MfiBtPrinterConnection*)connection) setTimeToWaitAfterWriteInMilliseconds:60];

                              NSError *error = nil;

                              BOOL didOpen = [connection open];

                              if (didOpen) {

                                  zebraPrinter = [ZebraPrinterFactorygetInstance:connection error:&error];

                                  if(error != nil) {

                                      return;

                                  }

                              }

               

              2) Check status multiple times

               

                          PrinterStatus *status=nil;

                          do {

                              status = [zebraPrinter getCurrentStatus:&error];

                              if (error) {

                                  NSLog(@"checkPrinterConnectionStatus: Printer status ERROR: %@", error);

                              }

                              if (status == nil) {

                                  NSLog(@"MyLog - getCurrentStatus returns nil");

                              } else if (status.isReceiveBufferFull) {

                                  NSLog(@"MyLog - Receive Buffer is full");

                              } else if (status.numberOfFormatsInReceiveBuffer) {

                                  NSLog(@"MyLog - There are still %ld jobs in receive buffer", status.numberOfFormatsInReceiveBuffer);

                              }

                          } while (status == nil || status.isReceiveBufferFull || status.numberOfFormatsInReceiveBuffer);

               

              But still sometimes I get the same error. I have noticed that I have started getting this error after receiving "Removing EASession (null) from list of sessionUUIDs" (i.e. Printer Connection is closed) though I did not close the connection.

               

              Could you please explain me what might be the reason that the printer connection is closing automatically?

               

              In advance thanks,

              Molay

                • Re: iMZ320 in iOS:Sometimes getCurrentStatus shows ErrorCode=7
                  Steven Si

                  If you received "Removing EASession" error while getting the "Malformed status response" error, it seems to me that the Bluetooth connection went bad. Please following the discussion in "iOS 11 Bluetooth Disconnection Issue with Zebra Printers" thread. Please make sure there is no case that two threads trying to access the same Bluetooth connection at the same time. We've seen the "Removing EASession" error in two cases, when the Bluetooth connection is closed prematurely or when  two tasks (threads) are access the same Bluetooth connection at the same time. The "iOS 11 Bluetooth Disconnection Issue with Zebra Printers" has described the both situations.

                    • Re: iMZ320 in iOS:Sometimes getCurrentStatus shows ErrorCode=7
                      Molay Ash

                      Hi Steven,

                      Thank you for your reply.

                      I can make sure that there is no case that two threads trying to access the same Bluetooth connection at the same time.

                       

                      It would be helpful if you could run the attached demo application:

                       

                      As you can see , It's a very simple test application where you need to connect with printer first. After that on each 30 seconds , the application will check the printer status.

                       

                      Step to follow:

                       

                      - First add breakpoint in line number 139 ,142,144,146 respectively inside ZebraPrinterManager.m file (I have already added the breakpoints)

                       

                      - Run the test app from source code.

                       

                      - Press 'Connect' button for connecting with the printer. Printer status will be changed on each 30 seconds.

                       

                      Now leave the app for sometimes (maximum for 30/40 minutes). Then you might notice that the application is paused in line number 139. Even if you remove the breakpoint, still there is no way you can out from do...while loop as it's fall in infinity loop.

                       

                      Please let me know if you face any issue to run the app.

                       

                      Thank you,

                      Molay

                        • Re: iMZ320 in iOS:Sometimes getCurrentStatus shows ErrorCode=7
                          Steven Si

                          Thanks for sharing the test code. I launched the test app about 50min ago. The app is still running and the counter keeps increment every 30sec. Now the counter is 112. I am running the test app on an iPhone 7 with iOS 11.2. I am not sure why you got the error. Make sure that you don't have a background process or task, or another application running in background that accidentally access Bluetooth connections. Those are the only things that I can think of.

                            • Re: iMZ320 in iOS:Sometimes getCurrentStatus shows ErrorCode=7
                              Molay Ash

                              Hi Steven,

                              Thank you for your reply.

                              Though we are not 100% sure, but we have noticed that if one specific hardware (in-fact a payment terminal) is connected via bluetooth then we are receiving "Removing EASession (null) from list of sessionUUIDs" during printer status checking. Also we are getting this error exactly 22 seconds later after receiving printer status.

                               

                              One thing: If we disconnect from the printer then we get

                              "Removing EASession (null) from list of sessionUUIDs".

                               

                              Could you please tell me why it is (null) instead of any uid? As I know , every EAaccessories should have unique id.

                               

                              Thank you,

                              Molay

                                • Re: iMZ320 in iOS:Sometimes getCurrentStatus shows ErrorCode=7
                                  Steven Si

                                  Hi Molay,

                                   

                                  Can you check the firmware version on your printer? With the latest firmware for iMZ320, which is "V73.20.01Z", we should see the message like something below, rather than null for UUID.

                                  13:10:57.579565 -0600 Zebra Removing EASession F777EB3C-3E0D-458E-898B-A75C98A0D453 from list of sessionUUIDs
                                  

                                   

                                  I have an iMZ320 with old firmware, with which I saw was exactly what you saw. After updating the firmware to "V73.20.01Z", the UUID is populated in the above message.

                                   

                                  The latest firmware is always available on zebra.com site, by searching the iMZ320 in the search box on zebra.com. Hope this helps.

                                    • Re: iMZ320 in iOS:Sometimes getCurrentStatus shows ErrorCode=7
                                      Molay Ash

                                      Hi Steven,

                                      Thank you for your reply.

                                      We have updated the firmware and now getting UUID.

                                       

                                      Regarding "Removing EASession from list of sessionUUIDs" and errorcode=7 issue:

                                      Could you please run my test app again ?

                                      But before running my test app, please also connect any other external accessories via bluetooth as well as printer to your iPhone.

                                      We have also noticed that we got this error when multiple bluetooth accessories among with printer are connected to iPhone.

                                       

                                      Thank you,

                                      Molay

                                       

                                        • Re: iMZ320 in iOS:Sometimes getCurrentStatus shows ErrorCode=7
                                          Steven Si

                                          I don't think the other Bluetooth accessories and connections should have interferences with the printer's Bluetooth connection in normal use cases. If we switch the running apps around during the testing, however, we may run into some situation we don't expect. For example, we re-pair a Bluetooth connection to an accessory or remove a connection, etc. during the tests. When we get into this type of situation, we need to make sure the app itself is able to handle the connection properly . For example, we disconnect the Bluetooth connection when a related view disappears, and we re-open the Bluetooth connection when the view re-appears, to make sure that the connection is not stale. This is important especially when we have more paired Bluetooth accessories and connections. Hope this helps.

                                            • Re: iMZ320 in iOS:Sometimes getCurrentStatus shows ErrorCode=7
                                              Rezaur Rahman

                                              Hello Steven,

                                              I am facing the same Problem like Molay Ash.

                                              And my findout is:

                                              1. The bluetooth connection some how got disconnected if I keeps getting Status information from the printer.
                                              2. We have to connect multiple bluetooth device with the phone to produce the issue. If only printer connected to the phone the issue will not produce.(In my case I have paired and connected the phone to My Mac and Printer). But once the issue is produced it will produce with single bluetooth device connection too.
                                              3. The issue is not producing if we soft reset the printer and run the application->(Tap Connect). But once we stop the application and restart the printer and relaunch the application->(Tap Connect) we are getting the error.
                                              4. Once the error occurred It keeps occurring until we reset the printer. Restarting the printer, restarting the application, resetting the Mobile Network does not resolved the issue.
                                              5. If once the printer gets disconnected from phone without no reason,  we will get ErrorCode=7 for getCurrentStatus until the connection gets back.
                                              6. The issue occurred only with iOS 11.

                                               

                                              Note: I am using iPhone SE with iOS:11.2.2 and printer firmware version: v73.20.01ZB

                                               

                                              Here is the Log I have produced from the attached Sample app I have modified from Molay's source. here you will noticed that at 2018-01-15 17:42:12 the printer got disconnected, But I can assure you that I have not stoped the printer.

                                               

                                              2018-01-15 17:37:16.753447+0600 Zebra[593:251082] [MC] Lazy loading NSBundle MobileCoreServices.framework

                                              2018-01-15 17:37:16.754279+0600 Zebra[593:251082] [MC] Loaded MobileCoreServices.framework

                                              2018-01-15 17:37:16.785699+0600 Zebra[593:251082] eaAccessory CoreAccessoryPrimaryUUID = D815B584-84F2-4207-8AB1-BC28E12FC6C4

                                              2018-01-15 17:37:21.545365+0600 Zebra[593:251140] accessoryd sessionResult = 1, useSocketInterace = 1, sessionID = 0x29

                                              2018-01-15 17:37:50.447813+0600 Zebra[593:251142] MyLog - Mon Jan 15 17:37:50 2018 - checkPrinterConnectionStatus started

                                              2018-01-15 17:37:51.942820+0600 Zebra[593:251142] MyLog - Mon Jan 15 17:37:51 2018 - got the status

                                              2018-01-15 17:38:20.446922+0600 Zebra[593:251285] MyLog - Mon Jan 15 17:38:20 2018 - checkPrinterConnectionStatus started

                                              2018-01-15 17:38:21.168761+0600 Zebra[593:251285] MyLog - Mon Jan 15 17:38:21 2018 - got the status

                                              2018-01-15 17:38:50.445632+0600 Zebra[593:251285] MyLog - Mon Jan 15 17:38:50 2018 - checkPrinterConnectionStatus started

                                              2018-01-15 17:38:52.428701+0600 Zebra[593:251285] MyLog - Mon Jan 15 17:38:52 2018 - got the status

                                              2018-01-15 17:39:20.445699+0600 Zebra[593:251285] MyLog - Mon Jan 15 17:39:20 2018 - checkPrinterConnectionStatus started

                                              2018-01-15 17:39:21.187787+0600 Zebra[593:251285] MyLog - Mon Jan 15 17:39:21 2018 - got the status

                                              2018-01-15 17:39:50.445220+0600 Zebra[593:251285] MyLog - Mon Jan 15 17:39:50 2018 - checkPrinterConnectionStatus started

                                              2018-01-15 17:39:51.934442+0600 Zebra[593:251285] MyLog - Mon Jan 15 17:39:51 2018 - got the status

                                              2018-01-15 17:40:20.444557+0600 Zebra[593:251285] MyLog - Mon Jan 15 17:40:20 2018 - checkPrinterConnectionStatus started

                                              2018-01-15 17:40:21.179446+0600 Zebra[593:251285] MyLog - Mon Jan 15 17:40:21 2018 - got the status

                                              2018-01-15 17:40:50.443976+0600 Zebra[593:251285] MyLog - Mon Jan 15 17:40:50 2018 - checkPrinterConnectionStatus started

                                              2018-01-15 17:40:51.911390+0600 Zebra[593:251285] MyLog - Mon Jan 15 17:40:51 2018 - got the status

                                              2018-01-15 17:41:20.443550+0600 Zebra[593:251285] MyLog - Mon Jan 15 17:41:20 2018 - checkPrinterConnectionStatus started

                                              2018-01-15 17:41:21.954289+0600 Zebra[593:251285] MyLog - Mon Jan 15 17:41:21 2018 - got the status

                                              2018-01-15 17:41:50.442833+0600 Zebra[593:251285] MyLog - Mon Jan 15 17:41:50 2018 - checkPrinterConnectionStatus started

                                              2018-01-15 17:41:51.939850+0600 Zebra[593:251285] MyLog - Mon Jan 15 17:41:51 2018 - got the status

                                              2018-01-15 17:42:12.888362+0600 Zebra[593:251082] CoreAccessories accessoryInfo for departure = {

                                                  ACCExternalAccessoryPrimaryUUID = "D815B584-84F2-4207-8AB1-BC28E12FC6C4";

                                                  IAPAppAccessoryCapabilitiesKey = 1;

                                                  IAPAppAccessoryDockTypeKey = "";

                                                  IAPAppAccessoryFirmwareRevisionKey = 001;

                                                  IAPAppAccessoryFirmwareRevisionPendingKey = "<null>";

                                                  IAPAppAccessoryHardwareRevisionKey = 001;

                                                  IAPAppAccessoryMacAddressKey = "AC:3F:A4:57:88:CB";

                                                  IAPAppAccessoryManufacturerKey = "Zebra Technologies";

                                                  IAPAppAccessoryModelNumberKey = iMZ320;

                                                  IAPAppAccessoryNameKey = XXXXJ154900263;

                                                  IAPAppAccessoryProtocolsKey =     {

                                                      "com.zebra.rawport" = 90;

                                                  };

                                                  IAPAppAccessorySerialNumberKey = XXXXJ154900263;

                                                  IAPAppAccessoryVehicleInfoInitialDataKey =     {

                                                  };

                                                  IAPAppConnectionIDKey = 43198937;

                                              }

                                              2018-01-15 17:42:12.888651+0600 Zebra[593:251082] Removing EASession 576FC282-12DD-420B-914B-83555070C923 from list of sessionUUIDs

                                              2018-01-15 17:42:12.889091+0600 Zebra[593:251082] MyLog - Mon Jan 15 17:42:12 2018 - accessoryDidDisconnect:Printer Disconnected

                                              2018-01-15 17:42:17.897552+0600 Zebra[593:251082] CoreAccessories accessoryInfo for arrival = {

                                                  ACCExternalAccessoryPrimaryUUID = "09AE6B5A-FFB5-4CDB-96E7-244D65261DCB";

                                                  IAPAppAccessoryCapabilitiesKey = 1;

                                                  IAPAppAccessoryCertDataKey = "908 bytes";

                                                  IAPAppAccessoryCertSerialNumberKey = "15 bytes";

                                                  IAPAppAccessoryDockTypeKey = "";

                                                  IAPAppAccessoryFirmwareRevisionKey = 001;

                                                  IAPAppAccessoryFirmwareRevisionPendingKey = "<null>";

                                                  IAPAppAccessoryHardwareRevisionKey = 001;

                                                  IAPAppAccessoryMacAddressKey = "AC:3F:A4:57:88:CB";

                                                  IAPAppAccessoryManufacturerKey = "Zebra Technologies";

                                                  IAPAppAccessoryModelNumberKey = iMZ320;

                                                  IAPAppAccessoryNameKey = XXXXJ154900263;

                                                  IAPAppAccessoryProtocolsKey =     {

                                                      "com.zebra.rawport" = 90;

                                                  };

                                                  IAPAppAccessorySerialNumberKey = XXXXJ154900263;

                                                  IAPAppAccessoryVehicleInfoInitialDataKey =     {

                                                  };

                                                  IAPAppConnectionIDKey = 43198938;

                                              }

                                              2018-01-15 17:42:17.897925+0600 Zebra[593:251082] eaAccessory CoreAccessoryPrimaryUUID = 09AE6B5A-FFB5-4CDB-96E7-244D65261DCB

                                              2018-01-15 17:42:17.902913+0600 Zebra[593:251082] MyLog - Mon Jan 15 17:42:17 2018 - accessoryDidConnect:Printer Connected

                                              2018-01-15 17:42:18.972967+0600 Zebra[593:252280] accessoryd sessionResult = 1, useSocketInterace = 1, sessionID = 0x2A

                                              2018-01-15 17:42:20.442250+0600 Zebra[593:251285] MyLog - Mon Jan 15 17:42:20 2018 - checkPrinterConnectionStatus started

                                              2018-01-15 17:42:50.441743+0600 Zebra[593:252281] MyLog - Mon Jan 15 17:42:50 2018 - checkPrinterConnectionStatus started

                                              2018-01-15 17:42:51.974730+0600 Zebra[593:252281] MyLog - Mon Jan 15 17:42:51 2018 - got the status

                                                • Re: iMZ320 in iOS:Sometimes getCurrentStatus shows ErrorCode=7
                                                  Steven Si

                                                  Hi Rezaur,

                                                   

                                                  I launched your test project on my phone, which connects to both iMZ320 and a Plantronics Voyager 5200 earphone. I pressed the "Connect" after the launch and left the phone untouched. Since then, I've not seen any error as you reported. The current value of the counter is 54 and still incrementing. This means the test has been about 25min or so. My phone is iPhone 7 on iOS 11.2.2. The iMZ320 is on v73.20.01Z.

                                                   

                                                  I am not sure how you reproduced the problem. Did you interact with the phone while the test was running? If the problem happened while we were doing some other things on the phone, then the story is different. By connecting with other Bluetooth accessories alone should not cause the disconnection problem.

                              • Re: iMZ320 in iOS:Sometimes getCurrentStatus shows ErrorCode=7
                                Nicola Lazzara

                                I've the same problem on Xamarin.Forms Application. Printing is ok in IOS 11.2.1 but never work in IOS 11.2.2.

                                 

                                The error is "malformed status responde" on CheckPrinterStatus method.

                                 

                                My printer is Zebra IMZ320. I use LinkOS.Plugin version 1.1.75

                                 

                                How i can fix? I'm sure that only one thread is open and only 1 ipad is connect with printer.