How to find out whether the paired bluetooth device is a zebra printer or not

// Expert user has replied.
S Senthil Subramanian 2 years 9 months ago
137 1 0

Hello,

Following is the way we are using to identify whether the paired bluetooth device is a zebra printer or not:
We are not using discovery mechanism yet, we will pair our printer to the mobile device through bluetooth and by using the BluetoothDevice object we will initiate the connection mechanism. When we are querying for the list of paired devices we will get all the devices paired from the mobile device and to find out which is the printer device we will have the following logic using BluetoothClass:

For getting the bluetooth class : BluetoothClass bluetoothClass = device.getBluetoothClass();
And the condition is,
if((bluetoothClass.getMajorDeviceClass() == BluetoothClass.Device.Major.IMAGING) && (bluetoothClass.hasService(BluetoothClass.Service.RENDER))){
// Then it is a printer
}

The above condition is failing for the ZD621R printer which i am using because getMajorDeviceClass() method is returning value as 7936 ( which is UNCATEGORIZED) and bluetoothClass.hasService(BluetoothClass.Service.RENDER) returns value as false. The same condition will work for all the previous models of zebra printers including ZD500R. Will there be any particular reason why this printer's bluetooth class is defined as UNCATEGORIZED and it doesn't have the service value as rendering? And is there any other way how we can identify the zebra printers via BluetoothDevice object?

Please suggest if there are any other better way to identify whether the paired bluetooth device is a zebra printer or not.

Thanks and Regards,
Arunvishal S

Please Register or Login to post a reply

1 Replies

S Steven Si

The factory default hardware confirmation of ZD621 printers does not include the Bluetooth classic. Therefore, the 7936 is returned from the bluetoothClass.getMajorDeviceClass(). If the ZD621 has the Bluetooth classic equipped, then the 1536 (0x600 for IMAGING) will be returned from the bluetoothClass.getMajorDeviceClass(). To verify if a printer has the Bluetooth classic equipped or not, use the SGD of the bluetooth via the Printer Setup Utility for Windows tool. In the response, the item of the bluetooth.le.controller_mode shows what type of the Bluetooth is equipped and enabled, i.e. the Classic, LE or both. Probably the ZD621 printer you have only has the LE.

### Bluetooth SGD
! U1 getvar "bluetooth"

<< example response >>
bluetooth.
bluetooth.discoverable : on , Choices: on,off
bluetooth.friendly_name : XXZJJ174600934 
bluetooth.version : 6.2 
bluetooth.date : 01/01/2020 
bluetooth.local_name : XXZJJ174600934 
bluetooth.address : AC:3F:A4:CD:C5:15 
bluetooth.bluetooth_pin : * 
bluetooth.short_address : AC3FA4CDC515 
bluetooth.radio_version : 5.2 
bluetooth.enable : on , Choices: on,off
bluetooth.connected : no 
bluetooth.minimum_security_mode : 3 , Choices: 1,2,3,4
bluetooth.connected_security_mode : nc 
bluetooth.bonding : on , Choices: on,off
bluetooth.clear_bonding_cache
bluetooth.enable_reconnect : iOS_only , Choices: off,iOS_only
bluetooth.le.
bluetooth.le.controller_mode : both , Choices: both,classic,le
bluetooth.le.power_class : 2 , Choices: 1-2
bluetooth.json_config_channel_enable : on , Choices: on,off
bluetooth.page_scan_window : 60 , Choices: 15,60
bluetooth.power_class : 2 , Choices: 1-2

To detect if the paired Bluetooth device is a printer or not, use the BluetoothClass.Device class. Refer to the Bluetooth Class Device & Service Generator to generate the const for comparison. For a Bluetooth printer device, the Major Device Class is IMAGING, while the Minor Device Class is the PRINTER. So the combined value is 1664 (or 0x680). Use the following comparison to determine if it's a printer or not.

if (bluetoothDevice.getBluetoothClass().getDeviceClass() == 1664) {
    // A Bluetooth printer
} else {
    // Not a Bluetooth printer
}

 

CONTACT
Can’t find what you’re looking for?