Skip to content

Error writing to connection Bluetooth LE Write timed out when using Zebra SDK through MAUI app #23

@budimartoyo

Description

@budimartoyo

The Zebra Printer SDK version 3.0.3337
Run on both net8-android34 and net9-android35 with the same result
Printer Zebra ZD421

I have been developing the MAUI app, and the Android manifest configured to allow use of Bluetooth as below:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
 
It can connect after creating the connection object of BluetoothLeConnection and call connection.Open() the Connected property is true and Printer Friendly Name is populated.
After that, get instance of printer object always throw error: Error writing to connection Bluetooth LE Write timed out on this line.

Connection connection = new BluetoothLeConnection(macAddress, 5000, 500, Android.App.Application.Context);
connection.Open();
if(connection.Connected) {
ZebraPrinter printer = ZebraPrinterFactory.GetInstance(connection);
}

{Zebra.Sdk.Comm.ConnectionException: Error writing to connection: One or more errors occurred. (Bluetooth LE Write timed out)
---> System.AggregateException: One or more errors occurred. (Bluetooth LE Write timed out)
---> System.IO.IOException: Bluetooth LE Write timed out
at Zebra.Sdk.Comm.Internal.Btle.ZebraBluetoothLeSocket.BluetoothLeOutputStream.Write(Byte[] data)
at Zebra.Sdk.Comm.Internal.Btle.ZebraBluetoothLeSocket.BluetoothLeOutputStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.MemoryStream.WriteAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)

But If I use, Android native with the same code it succeeds, and I can print.

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions