LinkOS with Xamarin and VS2015

Hi,

 

I'm writing a C# app to connect to a bluetooth printer and print labels off.

As part of this, I want to save the connected printer to an XML file, so that we can connect to it on subsequent runs without having to rediscover.

 

I've happily extracted the IDiscoveredPrinter details and saved them, and can read them back out again, but I am having problems recreating the printer.

I can create a DiscoveredPrinter, or DiscoveredPrinterBluetooth, but I cannot create or cast the relevant instances.

 

Any help please.

 

Thanks, Chris

Anonymous (not verified)
Hi Chris,Using the SDK, I

Hi Chris,

Using the SDK, I would recommend saving the IDiscoveredPrinter.Address to your file.  Then you can use:

IConnection connection = ConnectionBuilder.Current.Build("BT:" + address);

To create a new Bluetooth connection.

Robin

Vote: 
Vote up!
Vote down!

Points: 1

You voted ‘up’


Chris Dafnis
Hi Robin,Thank you, I had

Hi Robin,

Thank you, I had resorted to this, I was just wondering why you can't cast between interface and object like you can elsewhere in C#.

With regards to using IConnection, I am seeing a lot of Exceptions, such as:

ex = {Zebra.Sdk.Comm.ConnectionException: Could not open connection string "BT:AC:3F:A4:53:FC:FB"

  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/mscor...

Which I don't see using BluetoothConnectionInsecure, can you explain why please?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
Hi Chris, This is still an

Hi Chris,

This is still an early phase of the SDK and we will be adding in additional functionality in the future. 

Some of the reasons why casting between the object and interface don't work as you expect are because of the way we implemented the SDK to be cross platform.  The DiscoveredPrinter class does not really inherit from IDiscoveredPrinter.  The classes inheriting from the IDiscoveredPrinter interfaces are actually private (hidden) Android and iOS specific implementation classes.  We do intend to add the api's to recreate an IDiscoveredPrinter object

I'm not sure why you are seeing these exceptions.  Have you checked the Bluetooth security mode of the printer and Android device? One of the features we intend to implement next is the ability to create specific types of connections like the BluetoothConnectionInsecure connection. 

Robin

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Mike Fielden
I haven't found out how to

I haven't found out how to get a bluetooth connection to the printer working through Android. I have tried on a TC75 & Honeywell ScanPal EDA70. I see the bluetooth mac address in printer menu and pass it to the ConnectionBuilder.Current.Build("BT:" + address); But it still says Zebra.Sdk.Comm.ConnectionException: Could not open connection string "BT:F0:45:DA:AA:6F:2A" What bluetooth security settings are you thinking can be changed on the printer or android device. I have enabled all 3 bluetooth privileges in the manifest BLUETOOTH, BLUETOOTH_ADMIN, BLUETOOTH_PRIVILEGED. Using Zebra ZD620 and TC75 and they don't work connecting to each other. I can print using an IP Address and port, but if I try with bluetooth. NOTHING WORKS. Bluetooth paired to device also. Using Xamarin Android and VS 2017 15.7.4. I have also tried the developer demos and they fail to find the printer, although the Zebra Printer Setup Android App CAN connect and pair to it, as well as print a test page. Any help is appreciated.

This doesn't find the printer... No discovered devices 0 even though the printer is paired to the device?GitHub - Zebra/LinkOS-Xamarin-Samples at ZSDK_DevDemos

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


tok yanru
any updates on solution?

first time posting.
can i check if there are any solution for this problem?

im trying to save instance IDiscoveredPrinter into database so that user do not have to Scan,Select, Print each time the user wants to print.

private async void SelectPrinterView_OnPrinterSelected(IDiscoveredPrinter printer){}

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments