zebra bluetooth printers

ignaciomachinignaciomachin ✭✭USMember ✭✭

hi

Does anybody has created bindings for the zebra bluetooth printers
http://www.zebra.com/us/en/products-services/printers/printer-type/mobile/mz-series.html

thanks

pd: you can download the sdk here
http://www.zebra.com/link

«1

Posts

  • GustavoGalanGustavoGalan ✭✭ USMember ✭✭

    I am in the process. I am finding difficulties. Xamarin is also helping me on this.

    I am working with a iMZ320 Bluetooth printer.
    I think I have the bindings, however my test program cannot write to the printerconnection object.

    Have you done it since you last post.

    Thanks

  • ignaciomachinignaciomachin ✭✭ USMember ✭✭

    Hi Gustavo,

    Sorry for the delay, I was on vacation.

    I will work on this again sometime this week. We are a Zebra partner so I will try to contact them for help.

    Could you share your binding project with me?

    Thank,
    Ignacio

  • ignaciomachinignaciomachin ✭✭ USMember ✭✭

    Hi,
    I'm using this code, the printer is correctly located (all the accessories properties are returned correctly)
    The problem I have now is that the OutputStream is null

    var _accessoryList = EAAccessoryManager.SharedAccessoryManager.ConnectedAccessories;

    EAAccessory accessory = null;

    foreach (var obj in _accessoryList) {
    if (obj.ProtocolStrings.Contains ("com.zebra.rawport")) {
    accessory = obj;
    break;
    }
    }

    if ( accessory !=null){
    var session = new EASession (accessory, "com.zebra.rawport");

    if (session.OutputStream == null)

    }

    Have you done any progress from your part?

  • ignaciomachinignaciomachin ✭✭ USMember ✭✭

    Hi,

    I was able to compile the binding project, I had to include both libZSDK_API.a & libdtdev.a in the binding project.
    This is how my binding project looks like now:

    Any idea would be greatly appreciated

    [Model]
    public partial interface ZebraPrinterConnection {
    
        [Export ("open")]
        bool Open();
    
        [Export ("close")]
        void Close();
    
        [Export ("write:error:")]
        int Write(NSData data, out NSError error);
    
        [Export ("read:")]
        NSData Read(out NSError error);
    }
    
    [BaseType (typeof (NSObject))]
    public partial interface MfiBtPrinterConnection : ZebraPrinterConnection {
    
        [Export ("initWithSerialNumber:")]
        IntPtr Constructor (string aSerialNumber);
    
        [Export ("initWithSerialNumber:withMaxTimeoutForRead:andWithTimeToWaitForMoreData:")]
        IntPtr Constructor (string aSerialNumber, int aMaxTimeoutForRead, int aTimeToWaitForMoreData);
    
        [Export ("timeToWaitAfterWriteInMilliseconds")]
        int TimeToWaitAfterWriteInMilliseconds { set; }
    
        [Export ("timeToWaitAfterReadInMilliseconds")]
        int TimeToWaitAfterReadInMilliseconds { set; }
    }
    

    Nevertheless I cannot print, my program when I call the Open() method:
    This is the code I'm using:

    var _accessoryList = EAAccessoryManager.SharedAccessoryManager.ConnectedAccessories;
    Logger.CreateLog ("after try");
    EAAccessory accessory = null;
    Logger.CreateLog ("count " + _accessoryList.Count());
    foreach (var obj in _accessoryList) {
    EAAccessory a = obj;
    Logger.CreateLog (string.Concat( a.ProtocolStrings));
    if (obj.ProtocolStrings.Contains ("com.zebra.rawport")) {
    accessory = obj;
    //break;
    }
    }

    if (accessory == null) {
    Logger.CreateLog ("no printer found");
    //tmg.InfoAlert ("No Printer");
    return;
    } else {
    Logger.CreateLog ("prnter found");
    Logger.CreateLog (accessory.Connected.ToString());
    }

    Logger.CreateLog (accessory.SerialNumber.ToString());

    NSError err;
    NSData data = NSData.FromString("helo there");
    Logger.CreateLog("created data");
    this.printer = new MfiBtPrinterConnection(accessory.SerialNumber);
    if (printer!=null)
    Logger.CreateLog("printer created");
    else
    Console.WriteLine("printer failed");

    printer.Open();

    printer.Close();

  • MaxNunezMaxNunez ✭✭ CRMember ✭✭
    edited August 2013

    I am also working with this type of printer and I know how to connect it, but I don't know how to send commands to change font style (eg, bold) and font size. If anyone knows how to do post an example please.

    Thanks

  • Walid.3746Walid.3746 USMember

    I am binding only ZSDK_API.jar and i managed to connect to my ZEBRA RW 420.
    But I couldn't print since printing requires other methods that I have no reference to them still. Any help would be highly appreciated.

  • Walid.3746Walid.3746 USMember
    edited September 2013

    Ok it's working now! I was able to print today on Zebra RW420.

  • ignaciomachinignaciomachin ✭✭ USMember ✭✭

    Hi Walid,

    This is in Android correct?
    I do not believe you can use the RW420 in the iOS environment

  • ignaciomachinignaciomachin ✭✭ USMember ✭✭

    MaxNunez:

    I use ZPL, with this you can do that what you want. (bold, font size, etc)
    Go to zebra and download the programming guide

  • MatteoMonizzaMatteoMonizza ✭✭ ITBeta ✭✭

    Is there anyone that want to share the bindings file to connect to Zebra printers?

    Really appreciated

  • ignaciomachinignaciomachin ✭✭ USMember ✭✭

    Hi Matteo,

    I'm successfully printing in it but I got another path, I used Apple's EAAccessories classes. This allow me to simply bypass the Zebra SDK.

    I will post some code later today.

  • MatteoMonizzaMatteoMonizza ✭✭ ITBeta ✭✭

    ok thank you very much. My goal is to print a pdf (little form) with a Zebra printer via bluetooth. I know that is possible.

  • ignaciomachinignaciomachin ✭✭ USMember ✭✭

    Hi Matteo,

    Not sure if my code will help you in this case. I do generate my own ZPL code that I send to the printer. If you want to print a pdf file you might need to bind with the SDK.

  • MatteoMonizzaMatteoMonizza ✭✭ ITBeta ✭✭

    OK. Can you show me your code anyway?

  • ignaciomachinignaciomachin ✭✭ USMember ✭✭

    Here is the code for printing with the Zebra printer

    public class ZebraPrinter: NSStreamDelegate
    {
        static public EASession PrinterSession{ get; set; }
    
        private string printCommand;
    
        public override void HandleEvent (NSStream theStream, NSStreamEvent streamEvent)
        {
    
            if (printCommand == null)
                return;
            if (streamEvent == NSStreamEvent.HasSpaceAvailable) {
                var stream = theStream as NSOutputStream;
                if (stream != null) {
    
                    byte[] mybytes = Encoding.Default.GetBytes (printCommand);
                    stream.Write (mybytes, (uint)mybytes.Length);
                    printCommand = null;
                }
            }
        }
    
        // This is THE method :)
        public void PrintIt (string printingString)
        {
            printCommand = printingString;
            if (AppDelegate.Current.Manager.PrinterSession == null) {
                CreatePrinterSession ();
            } else {
                HandleEvent (AppDelegate.Current.Manager.PrinterSession.OutputStream, NSStreamEvent.HasSpaceAvailable);
            }
        }
    
        class EAAccessoryDelegateHandler: EAAccessoryDelegate
        {
    
            public void DisposeSession ()
            {
                var session = AppDelegate.Current.Manager.PrinterSession;
                if (session == null) {
                    return;
                }
                try {
                    if (session.OutputStream != null) {
                        session.OutputStream.Close ();
                        session.OutputStream.Unschedule (NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode);
                        session.OutputStream.Delegate = null;
                    }
                    session.Dispose ();
                    AppDelegate.Current.Manager.PrinterSession = null;
                } catch (Exception ee) {
                    Logger.CreateLog (ee);
                }
            }
    
            public override void Disconnected (EAAccessory accessory)
            {               
                DisposeSession ();
                accessory.Delegate = null;
            }
        }
    
        void CreatePrinterSession ()
        {
            try {
                var _accessoryList = EAAccessoryManager.SharedAccessoryManager.ConnectedAccessories;
    
                EAAccessory accessory = null;
                foreach (var obj in _accessoryList) {
                    EAAccessory a = obj;
                    if (obj.ProtocolStrings.Contains ("com.zebra.rawport")) {
                        accessory = obj;
                        break;
                    }
                }
                if (accessory == null) {
                    UIAlertView alert = new UIAlertView ();
                    alert.Title = "Error";
                    alert.Message = "no printer found";
                    alert.AddButton ("Ok");
                    alert.Show ();
                    return;
                }
                try {
                    accessory.Delegate = new EAAccessoryDelegateHandler ();
                    AppDelegate.Current.Manager.PrinterSession = new EASession (accessory, "com.zebra.rawport");
                    var mysession = AppDelegate.Current.Manager.PrinterSession;
                    if (mysession.OutputStream == null)
                        Logger.CreateLog ("output is null");
                    else
                        Logger.CreateLog ("output not null");
                    mysession.OutputStream.Delegate = this;
                    mysession.OutputStream.Schedule (NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode);
                    mysession.OutputStream.Open ();
                    Logger.CreateLog ("mysession.OutputStream.HasSpaceAvailable() :" + mysession.OutputStream.HasSpaceAvailable ().ToString ());
                    if (mysession.OutputStream.Error != null)
                        Logger.CreateLog (mysession.OutputStream.Error.DebugDescription + " | " + mysession.OutputStream.Error.Description + " | " + mysession.OutputStream.Error.LocalizedDescription + " | ");
                } catch (Exception ee) {
                    Logger.CreateLog (ee);
                }
            } catch (Exception ex) {
                Logger.CreateLog (ex);
            }
            Logger.CreateLog ("Finished creating session");
        }
    }
    
  • MatteoMonizzaMatteoMonizza ✭✭ ITBeta ✭✭

    Thank you very much

  • HafizUsamaHafizUsama USMember

    Hi Guys, I know this post is old but I'm also trying to make ZebraLink SDK work with Xamarin iOS. Currently I'm using Zebra iMZ320.

    I created binding project for libZSDK_API.a and translated pretty much entire API using Xamarin Objectify and later cleaned translated code to make it work.

    I'm successfully able to print using MfiBtPrinterConnection Write method but I'm facing issues using ZebraPrinter object. ZebraPrinter has methods like:

    -(id<ToolsUtil, NSObject>) getToolsUtil;

    -(id<GraphicsUtil, NSObject>) getGraphicsUtil;

    -etc.

    They look like this in my APIDefinition.cs

    Export ("getGraphicsUtil")]
    GraphicsUtil GetGraphicsUtil { get; }

    [Export ("getToolsUtil")]
    ToolsUtil GetToolsUtil();

    But when these methods/properties get complied, it doesn't get the definition right.
    Complier generated code look like this:

    [CompilerGenerated]
    public virtual GraphicsUtil GetGraphicsUtil {
        [Export ("getGraphicsUtil")]
        get {
            throw new ModelNotImplementedException ();
        }
    
    }
    
    [Export ("getToolsUtil")]
    [CompilerGenerated]
    public virtual ToolsUtil GetToolsUtil ()
    {
        throw new You_Should_Not_Call_base_In_This_Method ();
    }
    

    I wonder why Xamarin compiler is not generating the correct code? Am I doing something wrong? It looks like translating code like -(id<ToolsUtil, NSObject>) is tricky.

    I need to use ZebraPrinter instance to call methods like getToolsUtil and getGraphicsUtil for text and image printing. I'd really appreciate any suggestions or help. Thanks!

  • ClaudioSanchezClaudioSanchez ✭✭ USUniversity, Developer Group Leader ✭✭

    Hi guys,

    This sounds awesome! Is there any way you can post this on a public repository (i.e.:Github) so the whole community can benefit from it?

  • chrismiszturchrismisztur USMember
    edited August 2014

    Yo. I stumbled on this thread as I am trying to print over bluetooth using Unity.
    The demo XCode works fine but something is not right with my p/invoke impl as I keep getting error described here: https://km.zebra.com/kb/index?page=content&id=SO8786&actp=LIST_POPULAR

    http://postimg.org/image/3pfppm6yv/

    -chris

  • chrismiszturchrismisztur USMember
    edited August 2014

    --

  • ignaciomachinignaciomachin ✭✭ USMember ✭✭

    Hi,

    See my code above, it is a working code using the bluetooth API directly. I do not need to use the Zebra API at all, hence no P/Invoke needed :)

    Let me know if you have any problem reading the code.

    Ignacio
    http://www.laceupsolutions.com

  • chrismiszturchrismisztur USMember

    @ignaciomachin.

    I am going to end up needing the API to retrieve templates among other things...

  • chrismiszturchrismisztur USMember

    Got it working.
    Once I test I will probably publish to mono touch bindings repo.

  • michelizquierdomichelizquierdo ✭✭ USMember ✭✭

    HI Waldo,

    That is great news, send me the link when you do.

    BTW, last week I saw a truck driver using an iPod with an RW-420, I was under the impression that only the iRW320 was compatible with iOS, but it seems that that is not true. If you happen to know how to use a RW-420 , please let me know.

    Thank,
    Ignacio http://www.laceupsolutions.com

  • chrismiszturchrismisztur USMember
    edited September 2014

    @michelizquierdo

    For now I posted it here : https://developer.motorolasolutions.com/message/81614#81614

    Is the RW420 running LinkOS yet? I am testing on QLN420 and ZT410.

    -c

  • VishalBhalabarVishalBhalabar ✭✭ USMember ✭✭

    Hello All,

    I also dealing with printing on zebra printer in my Xamarin iOS app.
    For every print I have added commands to abort printing. This is the first command for any print.
    Its working fine, but sometime exception is occurred saying 'Error writing to connection'.
    This exception is handled correctly in code. But it will not print.

    How can I achieve printing successfully in case of above failure?

  • Adam.HillAdam.Hill USMember

    Has anyone tried to make Universal bindings for the iMZ series? Is the XXXlib.a in the Link-OS SDK even built for Universal (or multiple) yet?

  • AlessandroCaliaroAlessandroCaliaro ✭✭✭✭✭ ITMember ✭✭✭✭✭

    I've printed today to a imz(220???) via bluetooth in android sending plain text

  • ignaciomachinignaciomachin ✭✭ USMember ✭✭

    Adam Hill:

    Take a look at my code above, it is a working code for printing using ZPL without having to use the bindings.

    Cheers,
    Ignacio

    www.laceupsolutions.com

  • ignaciomachinignaciomachin ✭✭ USMember ✭✭

    Alessandro Caliaro:

    You can send ZPL using the same technique. Even print images :)

    Cheers,
    Ignacio

    www.laceupsolutions.com

  • AlessandroCaliaroAlessandroCaliaro ✭✭✭✭✭ ITMember ✭✭✭✭✭

    @ignaciomachin Thanks. This is only for iOS, I suppose...

  • michelizquierdomichelizquierdo ✭✭ USMember ✭✭

    Not really,

    A similar approach can be used in Android, as a matter of fact, I have both the MZ320 & the RW420 working in Android using the same approach.

    Cheer,
    Ignacio
    www.laceupsolutions.com

  • AlessandroCaliaroAlessandroCaliaro ✭✭✭✭✭ ITMember ✭✭✭✭✭

    @ignaciomachin but the code with EASession? It's a iOS class or is a Zebra API class? (I think it's not a .net class..)

  • nydnydnydnyd USMember

    Hi, does anyone has managed to send font to zebra printer via bluetooth?

  • AlessandroCaliaroAlessandroCaliaro ✭✭✭✭✭ ITMember ✭✭✭✭✭

    @nydnyd Send font? Do you mean to load some fonts to the printer? I think the better way is to connect printer to PC and send font using printer utility

  • michelizquierdomichelizquierdo ✭✭ USMember ✭✭

    I think the same.

    Not even sure if you can do it in the first place.

    Cheers.

    Ignacio

    www.laceupsolutions.com

  • nydnydnydnyd USMember

    @AlessandroCaliaro yes, I mean load the font to the printer. I'm using zebra printer iMZ320. But I need to do this for more than one printer, so I wonder does anyone has managed to do this?

  • chrismiszturchrismisztur USMember

    @nydnyd, take a look at Zebra Mirror. You can set up an FTP site where your printers check into and retrieve firmware updates and other files such as fonts. I recommend you ask this question on the Symbol/Zebra Launchpad site.

  • nydnydnydnyd USMember

    hi @chrismisztur thanks for your suggestion, I just posted this question on Zebra Launchpad site. By any chance, do you know on how to load the font by using CISDFCRC16?

  • DquaglioDquaglio ITMember

    Hi guys, I'm just starting to implement a print functionality in my app. But well I'm stuck at the beginning... After downloading and installing the sdk what should I do? How can I include in my project it?

Sign In or Register to comment.