20 Replies Latest reply on May 3, 2016 9:05 AM by Robin West

    LinkOS Binding Project for Xamarin.iOS

    Chris Misztur

      Attached is a Xamarin Binding project for LinkOS SDK.

       

      Sample code:

       InvokeInBackground (delegate {                  Console.WriteLine ("DEBUG::searching external accessories for zebra s/n");                    List<string> serialNumbers = new List<string> ();                  var connectedAccessories = EAAccessoryManager.SharedAccessoryManager.ConnectedAccessories;                  foreach (var accessory in connectedAccessories) {                      if (accessory.ProtocolStrings.Contains ("com.zebra.rawport")) {                          serialNumbers.Add (accessory.SerialNumber);                          Console.WriteLine ("DEBUG::found external zebra device with s/n:" + accessory.SerialNumber);                      }                  }                    if (serialNumbers.Count == 0) {                      Console.WriteLine ("DEBUG::no external zebra devices found!");                      return;                  }                    Console.WriteLine ("DEBUG::executing SDK API against s/n:" + serialNumbers [0]);                    MfiBtPrinterConnection thePrinterConn = new MfiBtPrinterConnection (serialNumbers [0]);                  //thePrinterConn.TimeToWaitAfterReadInMilliseconds = 1000;                  //thePrinterConn.TimeToWaitAfterWriteInMilliseconds = 1000;                    Console.WriteLine ("DEBUG::printer connected? : " + thePrinterConn.IsConnected.ToString ());                  bool success = thePrinterConn.Open ();                  Console.WriteLine ("DEBUG::printer connected? : " + thePrinterConn.IsConnected.ToString ());                    Console.WriteLine ("DEBUG::printer opened:" + success.ToString ());                    NSData data = NSData.FromString (@"^XA^FO20,20^A0N,25,25^FDThis is a ZPL test.^FS^XZ", NSStringEncoding.UTF8);                  NSError error = new NSError ();                    int bytesWritten = thePrinterConn.Write (data, out error);                    Console.WriteLine ("DEBUG::written bytes:" + bytesWritten.ToString () + ", error-code:" + (error==null ? "(null)" : error.Code.ToString ()));                    //TODO: does this have to be called before closing printer conn?                  ZebraPrinter zebraPrinter = ZebraPrinterFactory.GetInstance(thePrinterConn, out error);                  ToolsUtil toolsUtil = zebraPrinter.GetToolsUtil();                  //toolsUtil.PrintConfigurationLabel(out error);                    FileUtil fileUtil = zebraPrinter.GetFileUtil();                  var f = fileUtil.RetrieveFileNames(out error);                    PrinterStatus printerStatus = zebraPrinter.GetCurrentStatus(out error);                    string sgdValue = SGD.GET("bluetooth", thePrinterConn, out error);                    thePrinterConn.Close ();                  //thePrinterConn.DangerousRelease ();                    Console.WriteLine ("DEBUG::finished");              });