Channel
Channel information to your printer.
Overview
You use this object to specify your printer. To send data to your printer, you initialize this class and pass it to PrinterDriverGenerator.
If you change your channel, you initialize this class again.
Class methods
newWifiChannel
Create this class with an IP address of your printer to connect through a network.
Declaration
public static Channel newWifiChannel(final String ipAddress);
Parameters
| Name | Type | Description |
|---|---|---|
| ipAddress | String | IP address of your printer |
newBluetoothChannel
Create this class with a MAC address of your printer to connect through Bluetooth.
Declaration
public static Channel newBluetoothChannel(final String macAddress, final BluetoothAdapter bluetoothAdapter);
Parameters
| Name | Type | Description |
|---|---|---|
| macAddress | String | A Bluetooth MAC address of your printer |
| bluetoothAdapter | BluetoothAdapter | BluetoothAdapter of your application |
newBluetoothLowEnergyChannel
Create this class with a local name of your printer to connect through Bluetooth Low Energy.
Declaration
public static Channel newBluetoothLowEnergyChannel(final String localName, final Context context, final BluetoothAdapter bluetoothAdapter);
Parameters
| Name | Type | Description |
|---|---|---|
| localName | String | A local name for Bluetooth Low Energy of your printer |
| context | Context | Context of your application |
| bluetoothAdapter | BluetoothAdapter | BluetoothAdapter of your application |
newUsbChannel
Create this class to connect through a USB connection.
Declaration
public static Channel newUsbChannel(final UsbManager usbManager);
Parameters
| Name | Type | Description |
|---|---|---|
| usbManager | UsbManager | UsbManager of your application |
Properties
channelType
A channel type which is set during initialization.
Declaration
public ChannelType getChannelType();
channelInfo
Channel information such as an IP address and MAC address passed during initialization.
Declaration
public String getChannelInfo();
extraInfo
Printer information such as model name and serial number. This only has a value when the Channel is generated by PrinterSearcher. You can get the following values using ExtraInfoKey.
| Value | ExtraInfoKey |
Description | Network | Bluetooth | USB | BLE |
|---|---|---|---|---|---|---|
| Model name | ModelName | The printer's model name (e.g., QL-1110NWB)(*1) | ✔️ | ✔️ | ✔️ | ✔️ |
| IP address | IpAddress | The printer's IP address. | ✔️ | |||
| Serial number | SerialNumber | The printer's serial number | ✔️ | ✔️ | ||
| MAC address | MACAddress | The printer's MAC address. | ✔️ | |||
| Node name | NodeName | The printer's node name. | ✔️ | |||
| Location | Location | The printer's location string (empty if not set). | ✔️ | |||
| Bluetooth alias | BluetoothAlias | The printer's Bluetooth alias (a nickname set in Android settings)(*2). | ✔️ | ✔️ | ||
| Advertise local name | AdvertiseLocalName | The printer's local name advertised. | ✔️ | |||
| Is Secure Connection Supported | IsSecureConnectionSupported | Whether secure connection is supported ("1": Yes, "0": No) | ✔️ | |||
| Is Command Security Enabled | isCommandSecurityEnabled | Whether command access over the network is disabled. ("1": Yes, "0": No) | ✔️ |
Info
null is stored for entries without a check.
(*1) For TD-23XX series, Model name does not identify the model.
For example, if Model name is "TD-2350D". The model is either TD-2350D_203 or TD-2350D_300.
Use getPrinterStatus to identify the model.
(*2) Available for Android 11 and later versions.
Types
ChannelType
Enum type to specify a channel type you use to connect with printers.
Declaration
public enum ChannelType {
USB,
Wifi,
Bluetooth,
BluetoothLowEnergy,
}
ExtraInfoKey
Enum type to get a value from extraInfo.
Declaration
public enum ExtraInfoKey {
ModelName,
SerialNumber,
MACAddress,
NodeName,
Location,
BluetoothAlias,
AdvertiseLocalName,
IpAddress,
}