StarIO StarPRNT Android SDK
StarIO StarPRNT Android SDK
StarIO StarPRNT Android SDK
Tools Needed:
• JDK 6
• Eclipse
• Android SDK Manager
• ADT (Android Development Tool) Plugin for Eclipse
• USB Windows Driver by Android Device Manufacturer
• StarIO Android SDK
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
❖Portable Printer
When using StarPRNT emulation:
To use the StarPRNT emulation, set the emulation setting of the printer to
“StarPRNT”. To change the emulation, proceed as follows. For SM-L200 and SM-L300,
it does not need to switch the emulation.
2. Press and hold the POWER button and the FEED button simultaneously. As soon as
the ERROR lamp flashes five times, release the buttons. The emulation switchover
takes place automatically.
3. After setting a paper, close the printer cover. The set emulation is printed out.
ESC/POS : EMU = ESC/POS
StarPRNT : EMU = StarPRNT
2
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
Table of Contents
3
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
This manual is designed to help you understand StarIO and how to build an Android
application to interact with Star Micronics Printers. It is important to understand the basics of
the Java language. Although this SDK is for Android, there are SDKs available for many
different operating systems and programming languages at our Global Support Site. Check the
Developers Section of our site for the newest SDKs, technical documentation, FAQs, and many
more additional resources.
Key Legend:
CAUTION:
4
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
The below chart summarizes the Star Printer Models supported on Android Operating Systems.
Android OS Versions 3.1 and higher support USB, Bluetooth and Network Interfaces.
Android OS Versions 3.0 and lower support Bluetooth and Network Interfaces.
3.0
Model Interface 2.1 2.3 3.1 - 7.1 4.0 - 7.1
2.2
SM-S210i *
Bluetooth
(JP model only)
SM-S220i *
(Models for US and Bluetooth
Europe only)
SM-S230i USB
(Models for US and
Europe only) Bluetooth
SM-T300i * Bluetooth
SM-T400i * Bluetooth
SM-L200 Bluetooth
SM-L300 Bluetooth
USB
mPOP
Bluetooth
◆
5
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
Star Printer
Bluetooth Setting
Sample Receipts
Text Formatting
Raster Graphics
Sample Images
Port Discovery
1D Barcodes
2D Barcodes
USB Setting
Get Status
MSR
Model Interface
*1
Firmware version 3.0 or later is required.
*2
When using Line Mode commands, printing in Russian and Simplified Chinese is not supported.
*3
When using Line Mode commands, Simplified Chinese will be supported from firmware version 1.1.
*4
PDF417 will be supported from firmware version 1.1.
*5
MSR capability will be supported from firmware version 2.0.
Note: This SDK offers the most popular features, but not all printer functionality has been included. The commands not
included in this SDK application are available in the StarPRNT Command Manual.
6
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
These screenshots were captured using an Android 4.0 tablet. Screenshots and wording can
vary between Android operating systems.
USB Interface
1. The Android device must be running OS Version 3.1 or higher. (Versions 3.0 and lower
are incompatible with USB tethering to external devices like printers.)
3. The USB cable needed can vary by tablet. Most Android tablets do not support the
common A to B USB cable. Some require mini/micro USB cables or adapters/docks.
Review the specifications for your tablet to ensure the correct cable is being used;
there is no specific pin out for Star USB Printers.
4. When connecting multiple devices using a USB hub, the recommended cascade
connection is maximum one stage.
The maximum number of devices which can be connected at the same time is 4.
7
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
Depending on Android device, the above message may appear the first time you interact (get
status or print) with the Star USB Printer.
To remedy this, enter the following code into the AndroidManifest.xml and device_filter.xml
file.
[AndroidManifest .xml]
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
</intent-filter>
<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/device_filter" />
[device_filter.xml]
<?xml version="1.0" encoding="utf-8"?>
<resources>
<usb-device class="255" subclass="66" protocol="1" />
<usb-device vendor-id="1305" product-id="0067" /> … SM-S230i mobile printer
</resources>
8
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
Bluetooth
All Star Bluetooth devices have each initial device name as a factory default setting, such as "Star
Micronics" and "DK-AirCash". When using multiple devices which have same device name, it is
useful to change the device name for identifying each device easily.
You can change the LAN/Bluetooth settings of Star POS devices such as a device name setting by
using the Star Setting Utility provided by Star Micronics. Please download it from Google play.
1. Ensure Bluetooth is enabled and the Star POS Device is powered on.
When the security setting of the Star POS device is set to SSP, press the PAIR button for
more than 5 seconds to make it available for pairing.
2. Tap Settings.
3. Tap Bluetooth to ON.
9
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
5. If use the “PIN Code”, enter the PIN number. The factory default for standard Star POS
Device is “1234”. (Portable Printer only)
10
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
1. Tap Settings.
2. Tap Security.
11
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
It is assumed Eclipse has already been configured to support Android development. Should you
need assistance with this, refer to Star’s Android Setup Guide in the documentation folder of
this SDK package.
1. Execute Eclipse.
12
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
13
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
14
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
4. Browse to the location where the Star SDK is saved. Click Finish.
15
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
1. Click AndroidManifest.xml.
16
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
1. Choose PrinterTypeActivity.java.
2. Click the green arrow.
Tip: The above error occurs if you attempt to reinstall the .apk from a different host.
To remedy it, delete the application on your Android device and rerun the app.
17
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
StarIO uses specific port names to identify what port will be used. If these port names are not
entered correctly, the application will fail to communicate with the printer. For detailed
information, please see here.
Even though you input it, the application fails getPort method and cannot print or cannot get
status.
18
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
2. Tap the desired command type to access the samples for that mode. The mode chosen
results in which samples can be sent to the printer.
19
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
Line Mode Printers accept commands and print data line-by-line. The data is transferred to
the printer in small pieces, allowing developers to customize receipt output with commands
in any place they are needed. This mode alone can only make use of Device Fonts installed on
the printer, which can be less visually appealing than TrueType Fonts.
Raster Mode Printers receive all print data graphically, allowing them to natively support the
printing of engaging TrueType Fonts and output receipts at a lightning fast pace. Coding
Raster commands is more complicated than Line Mode commands, as Raster commands
require the entire receipt to be generated in graphical data before being sent to the printer.
20
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
USB Printers
1) USB:
If only one Star USB Printer is connected, using “USB:” with no parameters will
automatically communicate to the only printer connected.
2) USB:SN:<Serial Number>
Add the serial number after “USB:SN:” without brackets.
21
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
2. Tap the interface type of the printer you want to connect to.
When tapping "USB", the model names of USB printers you can connect to be displayed.
3. Tap the name of printer you want to connect to. The printer’s serial number and model
name are displayed at the same time.
22
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
1. Tap “Search” to find all connected Star Printers. Alternatively, the device name can be
manually typed into the “PortName” field. See here for details.
2. Tap the interface type of the printer you want to connect to.
When tapping "Bluetooth", the port names of paired printers you can connect to are displayed.
23
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
There are three types of port details that can be used for Star Bluetooth Printers:
1. BT: If only one Star Bluetooth Printer is connected, using “BT:” with no parameters
will automatically communicate to the only printer connected.
2. BT:<DeviceName> Add the full device name after “BT:” without brackets. This is
case sensitive so ensure it matches exactly.
3. BT:<MAC Address> Add the printer’s MAC Address after “BT:” without brackets.
24
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
This setting shifts the Connection retry setting for StarIO between ON and OFF.
The retry time value is the timeout value specified in getPort method parameter.
The operation of SDK can be checked by using the AVD (Android Virtual Device).
It is impossible to communicate with Star Bluetooth/USB printers.
25
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
26
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
StarIO – (StarIOPort3.1.jar)
The file StarIOPort3.1.jar is a library that you can include into your Java projects to expose
StarIO methods.
The StarIO SDK contains two library files. Use the one which corresponds to the Android OS
Version your application is being developed for.
1. Drag the appropriate StarIO library file into the Project Explorer from the SDK package
27
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
Library management has been changed starting from Android SDK Tools r17. It is essential to
order the StarIOPort JAR before StarIOSDK/src. This method presented no problem from
Android SDK Tools r16 and lower, but caused the application to crash beginning with r17.
Star Micronics rectified this issue in the StarIO Android SDK V2.4. Please ensure the same
caution is taken when using the StarIOPort JAR in your own application.
3. Highlight the StarIOPort JAR and relocate it to above the application code
28
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
Android OS V2.1:
29
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
StarIO Port class includes 3 properties; portName (String), portSettings (String), and Timeout
(int).
These 3 variables will be “read only” if accessed directly. To assign them use
getPort(portName,portSettings,timeout); which will allow you to pass in
variables to this methods which then assigns the 3 class variables with values.
portName is what you will be using to specify the port of communication to the printer.
Ex. “BT” / USB:
This function prevents next print data from being printed incorrectly when the Bluetooth
connection is disconnected during data transmission.
30
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
timeout is a millisecond timeout controlled internally and is used for communication in the
APIs (this parameter guarantees that all of the below APIs will complete in a bounded amount
of time, but does NOT guarantee the exact timeout length)
31
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
● Method
getPort
getPort is what you will be using to “open” the port to the printer. Using one of the valid
inputs for portName and portSettings as mentioned previously before this, you can pass your
connection string into the StarIO class so that it will correctly set its private variables.
StarIOPort is a part of StarIO and this will allow you to create a “port” handle. The above
example shows the port being created and set to null then being assigned the actual port
hook on the following line that contains getPort.
Always use a try, catch when using getPort. If the port cannot be opened
because of connection problems, your program will crash unless you use a
try, catch like the above example.
32
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
In case your application prints to bluetooth printers, the getPort method may sometimes fail
to get status or print as the result of failing to connect with the bluetooth device depending
on devices and a use environment.
When "portable;l" is specified for the portSetting parameter of the getPort method, a retry
will be performed in case of a failure of connection with the bluetooth device.
The retry will be repeated during a time specified in the timeout parameter and the
StarIOPortException will occur if a connection does succeed within a timeout time.
When getPort fails a StarIOPortException is thrown. Please repeat the operations mentioned
in article 2 and 3 below (see getPort Retry Flow):
1. getPort fails
(StarIOPortException is thrown).
(Remark)
The number of attempts to execute getPort to obtain a port handle depends on the Host
device(Android Device). Some devices have a higher failure rate than others, and may require
additional attempts to getPort. Please decide based on tests conducted with your Android
device.
33
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
searchPrinter
PortInfo class of return value includes, PortName, MAC address, Printer Model name, USB
Serial Number and you can get them by String getPortName(), String getMacAddress(), String
getModelName() and getUSBSerialNumber() method.
This sample shows, get connected Bluetooth devices and output to log.
searchPrinter detects not only Star portable printers but also any Bluetooth
devices. To use original name, just search specific printers.
34
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
readPort
This method reads data from the device. Only use this if you really need to read raw
bytes from the printer.
Parameters:
Returns:
The number of bytes that were actually read. Under some interface types, this
function will succeed even when no data was read in. Your application should call this
function a limited number of times until the expected data has been read in or until
an application determined retry threshold has been reached.
Throws:
35
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
releasePort
Parameters:
port – StarIOPort type representing a previously initialized port.
36
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
writePort
Please keep in mind this is the simplest way to send data to the printer.
The SDK has code in printToPrinter that is more complex than this but that code block will
show you how to verify data transmission to the printer whereas this code is just dumping it:
//Set a byte array to send to the printer
//command = { A, B, C, D, Feed 3mm, Full Cut}
Byte[] command = new Byte[]{ 0x41, 0x42, 0x43, 0x44, 0x1B, 0x7A, 0x00, 0x1B, 0x64, 0x02 };
try
{
port.writePort(command, 0, command.length);
}
catch (StarIOPortException e)
{
//There was an error writing to the port
}
Parameters:
writeBuffer - Contains the output data in a byte array.
offset - Specifies where to begin pulling data from writeBuffer .
size - Number of bytes to write.
Throws:
StarIOPortException - when a communication failure occurs
37
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
retreiveStatus
public StarPrinterStatus retreiveStatus ()
throws StarIOPortException
This method retrieves detailed status from the printer with StarIO.
Returns:
StarPrinterStatus structure giving the current device status
Throws:
StarIOPortException - when a communication failure occurs
This method uses a class structure that is included with StarIO called StarPrinterStatus
This structure gives the printer's status in both boolean and binary form.
if (status.offline == false)
{
if (status.blackMarkError == true) {
//There was a black mark error
}
if (status.compulsionSwitch == true) {
//Cash drawer is open
}
else {
//Cash drawer is closed
}
}
else {
//If true, then the printer is offline.
}
38
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
headThermistorError Head Thermistor Error boolean You can check status of Head Thermistor.
" true " : Head thermistor detects an abnormal value.
" false " : Head thermistor does not detect an abnormal
value.
offline ONLINE/OFFLINE boolean You can check status of Online or offline.
Status " true " : Printer is Offline.
" false " : Printer is Online
overTemp Stopped by high head boolean " true " : Printer is stopped by head temperature.
temperature " false " : Printer is not stopped by head temperature.
presenterPaperJamError Presenter Paper Jam boolean You can check status of Paper Jam in Presenter.
Error " true " : Paper jam occurs in presenter .
" false " : Paper jam does not occur in presenter .
presenterState Presenter Paper int You can check status of Presenter.
Position 0 : State where there is no paper in presenter
1 : State where paper is supplied (loop state)
3 : State where paper is discharged (Can be pulled out)
6 : State where paper is recovered
7 : State where paper is pulled out.
raw Byte column of status byte[63] Byte column of status
(example : HEX 23 86 00 00 00 00 00 00 00)
rawLength raw length int raw length
39
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
SM-
SM- SM- SM-
SM- SM- T300i SM-
Member name S210i S220i S230i mPOP
L200 L300 SM- T400i
* ** **
T300
blackMarkError ✔ ✔ ✔ ✔ ✔ ✔ ✔
compulsionSwitch ✔
coverOpen ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
cutterError ✔
etbAvailable ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
etbCounter ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
headThermistorError ✔
offline ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
overTemp ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
presenterPaperJamError
presenterState
raw ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
rawLength ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
receiptPaperEmpty ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
receiptPaperNearEmptyInner
receiveBufferOverflow
unrecoverableError ✔
voltageError ✔
40
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
beginCheckedBlock
public StarPrinterStatus beginCheckdBlock () throws StarIOPortException
This method is used in combination with endCheckedBlock and checks the completion of
printing. To check if the whole data is completely printed, you need to run this method just
before sending print data and endCheckedBlock just after sending print data.
Returns:
StarPrinterStatus structure giving the current device status
Throws:
StarIOPortException - when a communication failure occurs
- when the printer is off line
41
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
endCheckedBlock
public StarPrinterStatus endCheckdBlock () throws StarIOPortException
If printing is not completed before the timeout (*1) or a printer error occurs during printing,
StarIO throws a StarIOPortException.
(*1) To set the timeout value for endCheckedBlock execution time, please call
setEndCheckedBlockTimeoutMillis method of StarIOPort object.
The default timeout value is the value specified in getPort method parameter.
Please adjust the endCheckedBlockTimeoutMillis value to be longer than printing time.
If printing is not complete before endCheckedBlockTimeoutMillis value is reached, a
StarIOPortException will be thrown.
The minimum timeout value that can be specified in the getPort or
setEndCheckedBlockTimeoutMillis methods is 10 seconds. If less than 10 seconds is
specified, StarIO will default to 10 seconds.
Returns:
StarPrinterStatus structure giving the current device status
Throws:
StarIOPortException
- An error sending the command (such as Off-Line)
- No response for the completion of printing from a printer within the timeout
42
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
try
{
port = StarIOPort.getPort(portName, portSettings, 10000, context);
//Printing
byte[] command = PrinterFunctions.createPrintData(paperWidthInch);
port.writePort(command, 0, command.length);
if (status.offline == true) {
//If true, then the printer is offline.
}
}
catch (StarIOPortException e)
{
Log.d("StarIOSample", "An timeout error has occurred during printing.");
}
finally
{
if (port != null)
{
try
{
StarIOPort.releasePort(port);
}
catch (StarIOPortException e) {}
}
}
43
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
setEndCheckedBlockTimeoutMillis
This method sets the endCheckedBlock method's timeout value [unit: ms]
If it takes a long time to print, please increase this value to allow for enough time to
complete the print job.
Default value is the timeout value designated by getPort method.
getFirmwareInformation
This method gets a model name and firmware version of the printer.
It returns Map<String, String> as an acquisition result.
Returns:
Gets a model name from the return value by setting the Key to “ModelName”.
Gets a firmware version from the return value by setting the Key to “FirmwareVersion”.
Throws:
StarIOPortException - when a communication failure occurs
Note:
・If it failed to get information, it returns an empty string.
44
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
getStarIOVersion
Returns:
StarIO Version
45
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
StarBluetoothManager Class:
StarBluetoothManager Class specifies various settings of the Bluetooth interface.
It can not be used with StarIOPort Class.
●Constructor
StarBluetoothManager
public StarBluetoothManager(String portName, String portSetting, int timeoutMillis,
StarBluetoothManager.StarDeviceType starDeviceType)
throws StarIOPortException
Parameters:
portName – the port name for connecting to the device.
Ex. BT:StarMicronics
timeoutMillis
- timeout is a millisecond timeout controlled internally and is used for
communication in the APIs (this parameter guarantees that all of the
below APIs will complete in a bounded amount of time, but does NOT
guarantee the exact timeout length)
starDeviceType
– the type of the device to be searched
Ex. StarDeviceTypeDesktopPrinter
Throws:
StarIOPortException – when starDeviceType is set to StarDeviceTypePortablePrinter
– when portName is not set to BT:
46
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
●Method
open
public void open()
Throws:
StarIOPortException - when a communication failure occurs
loadSetting
public void loadSetting()
This method gets the value specified from the star Bluetooth device.
Throws:
StarIOPortException - when a communication failure occurs
close
public void close()
This method is used to close communication with the star Bluetooth device.
Throws:
StarIOPortException - when a communication failure occurs
apply
public void apply()
47
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
getBluetoothDeviceName
public String getBluetoothDeviceName()
This method gets the Bluetooth device name which was acquired by the loadSetting method
or specified by the setBluetoothDeviceName method. Use this method after calling the
loadSetting method or the setBluetoothDeviceName method.
Returns:
BluetoothDeviceName
setBluetoothDeviceName
public void setBluetoothDeviceName( string BluetoothDeviceName)
This method sets the Bluetooth device name of at least 1 character, with a max length of 16
characters.
To change the Bluetooth device name, execute the apply method after the
setBluetoothDeviceName method.
Parameters:
BluetoothDeviceName
Throws:
StarIOPortException – when any invalid characters are used
– when the length of the set character string is not between 1 to
16 characters.
Valid characters:
0-9 a-z A-Z ; : ! ? # $ % & , . @ _ - = Space / * + ~ ^ [ { ( ] } ) | \
48
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
getiOSPortName
public String getiOSPortName()
This method gets the iOS port name which was acquired by the loadSetting method or
specified by the setiOSPortName method. Use this method after calling the loadSetting
method or the setiOSPortName method.
Returns:
iOSPortName
setiOSPortName
public void setBluetoothDeviceName( string iOSPortName)
This method sets the iOS port name of at least 1 character, with a max length of 16
characters.
To change the iOS port name, execute the apply method after the setiOSPortName method.
Parameters:
iOSPortName
Throws:
StarIOPortException – when any invalid characters are used
– when the length of the set character string is not between 1 to
16 characters.
Valid characters:
0-9 a-z A-Z ; : ! ? # $ % & , . @ _ - = Space / * + ~ ^ [ { ( ] } ) | \
49
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
getPinCode
public String getPinCode()
This method gets the PIN code which was specified by the setPinCode method. Use this
method after calling the setPinCode method.
Returns:
PinCode
setPinCode
public void setPinCode( string pinCode)
The method sets the PIN code of 4 characters for SM-L200/SM-L300 and that of at least 4
character, with a max length of 16 characters for other Star Bluetooth devices.
To change the PIN code, execute the apply method after the setPinCode method.
Parameters:
PinCode Ex. 1234
Throws:
StarIOPortException – when any invalid characters are used
– when the length of the set character string is not between 4 to
16 characters.
50
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
getAutoConnect
public boolean getAutoConnect()
This method gets the value specified of Auto Connection which was acquired by the
loadSetting method or specified by the setAutoConnect method. Use this method after
calling the loadSetting method or the setAutoConnect method.
Returns:
true - when AutoConnection setting is ON
false - when AutoConnection setting is OFF
setAutoConnect
public void setAutoConnect( boolean autoConnect)
51
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
getSecurityType
public StarBluetoothManager.StarBluetoothSecurity getSecurityType()
This method gets the Bluetooth security type(SSP or PIN Code) which was acquired by the
loadSetting method or specified by the setSecurityType method. Use this method after
calling the loadSetting method or the setSeurityType method.
Returns:
StarBluetoothManager.StarBluetoothSecurity
setSecurityType
public void setSecurityType( StarBluetoothManager.StarBluetoothSecurity securityType)
This method sets the Bluetooth security type(SSP or PIN Code) of star Bluetooth device.
To change the Bluetooth security type, execute the apply method after the setSecurityType
method.
Parameters:
securityType Ex. StarBluetoothManager.StarBluetoothSecurity.SSP
getPortName
public String getPortName()
This method gets the port name specified by the StarBluetoothManager constructor.
Returns:
portName
getPortSetting
public String getPortSetting()
This method gets the port setting specified by the StarBluetoothManager constructor.
Returns:
portSetting
52
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
getTimeoutMillis
public String getTimeoutMillis()
Returns:
timeoutMillis
getDeviceType
public String getDeviceType()
This method gets the star Device type specified by the StarBluetoothManager constructor.
Returns:
StarBluetoothManager.StarDeviceType
isOpened
public boolean isOpened()
Returns:
true - The port is opened.
53
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
This SDK also has page and section references to the StarPRNT Command Manual for more
information so please download and study it if you need more detail on a specific command.
1. Tap “Star Portable Printers / mPOP” to use a thermal printer and “Star Impact Dot Matrix
Printers” to use a dot printer.
2. Select “Line Mode Commands” or “Raster Mode Commands”. When a dot printer is used, the
screen will jump to the corresponding Line Mode command page.
The difference is detailed here.
54
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
55
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
Automatically detects which Star Micronics Printers are connected to the network. Tap the
printer to connect to it. This feature is documented in greater detail here. USB printers do
not support this feature.
56
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
Displays rules for manually entering the printer’s port data into the “PortName” field.
Manually entering port data is unnecessary if Port Discovery is used.
57
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
StarPrinterStatus
public boolean retreiveStatus() See status return values here
offline false = printer online; true = printer offline
other See status return values here
58
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
Prints a premade sample receipt in the chosen command type and the chosen language.
Select the sample’s width and tap “OK” to print it. This part of the source code is heavily
commented to demonstrate how receipts can be fully customized.
When using Line Mode commands, printing in Russian and Simplified Chinese
is not supported with SM-210i, SM-S220i, SM-S230i, SM-T300i and SM-T400i.
When using Line Mode commands, Simplified Chinese will be supported from
firmware version 1.1 for SM-L200.
59
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
1D Barcodes ◆Line
Configure 1D Barcode
ESC b n1 n2 n3 n4 d1 ... dk RS
n1 = Barcode Type
0 = UPC-E * 1 = UPC-A * 2 = JAN/EAN8 * 3 = JAN/EAN13 *
4 = Code39 5 = ITF 6 = Code128 7 = Code93 8 = NW-7 *
* These barcodes are supported by Star Printers, but no example is in the sample application.
Note: 1D Barcode samples are not available for Raster Mode in this application. It is recommended
to send barcodes graphically to the printer when using Raster Mode.
60
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
2D Barcodes ◆Line
QR Code
Select QR Code
There are 5 commands below that are very important to printing a good QR Code.
(1) Set QR Code Model # ESC GS y S 0 n
(2) Set QR Code Correction Level ESC GS y S 1 n
(3) Set QR Code Cell Size ESC GS y S 2 n
(4) Set QR Code Data ESC GS y D 1 NUL nL nH d1…dk
(5) Print the QR Code ESC GS y P
This is the order in which commands need to be sent to print the QR Code:
QR Model + QR Correction Level + QR Cell Size + QR Data + Print QR Code
Refer to the StarPRNT Command Manual for a listing of all QR Code commands.
Note: 2D Code samples are not available for Raster Mode in this application. It is recommended to
send barcodes graphically to the printer when using Raster Mode.
61
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
PDF417
Select PDF417
(1) Set PDF417 barcode size ESC GS x S 0 n p1 p2
(2) Set PDF417 ECC (Security Level) ESC GS x S 1 n
(3) Set PDF417 module X direction size ESC GS x S 2 n
(4) Set PDF417 module aspect ratio ESC GS x S 3 n
(5) Set PDF417 barcode data ESC GS x D nL nH d1 d2 … dk
(6) Print PDF417 barcode ESC GS x P
This is the order in which commands need to be sent to print the PDF417 barcode:
PDF417 Size + PDF417 ECC + PDF417 X-dim + PDF417 Ratio + PDF417 Data + Print PDF417
Refer to the StarPRNT Command Manual for a listing of all PDF417 commands.
Note: 2D Code samples are not available for Raster Mode in this application. It is recommended to
send barcodes graphically to the printer when using Raster Mode.
PDF417 are not supported by dot printers.
62
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
*English screen
63
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
Note: Raster Mode receives graphical data only so this sample is not compatible. For a data
formatting example in this mode, refer to Raster Graphical Text Printing.
64
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
Raster Mode converts all print data into image data and then outputs it to the printer. This
enables Star Printers to print at high speeds, regardless of outputting receipts with only text or
text and logos/coupons. As there are many options on how to customize output in Raster Mode,
refer to the StarPRNT Command Manual for a listing of all Raster commands. These commands are
also conveniently listed right on the Android device by tapping the Help button on the screen.
Note1: Line Mode cannot process graphical data so this sample is not compatible. For a data
formatting example in this mode, refer to Text Formatting.
Note2: If send large amounts of raster data command, use beginCheckedBlock / endCheckedBlock
method “before / after” sending data by writePort method for preventing “data detective”.
Detail refer to the "PrintBitmap" method in the "PrinterFunctions.java".
65
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
Use the dropdown box to select one of four different sample images to print via Raster Graphics.
Note: The images in this sample are pre-formatted for 80mm wide receipts. If the printer in use is
smaller or wider than 80mm, the image will not be automatically scaled.
Raster Mode converts all print data into image data and then outputs it to the printer. This
enables Star Printers to print at high speeds, regardless of outputting receipts with only text or
text and logos/coupons. As there are many options on how to customize output in Raster Mode,
refer to the StarPRNT Command Manual for a listing of all Raster commands. These commands are
also conveniently listed right on the Android device by tapping the Help button on the screen.
66
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
67
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
Connects to the Bluetooth device which is specified for PortName and changes various
settings of the Bluetooth interface.
The values applied with this method are effective after turning the device
off and on and paring again.
68
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
Connects to the USB device which is specified for PortName and changes various settings
of the USB interface.
The values applied with this method are effective after turning the device
off and on.
69
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
Star Micronics prides itself as the industry leader in great POS products and with great power
comes great responsibility. Below is a tips section just to help you get on the fast track to
software development with StarIO.
TIP #1: If you are going to be coding a large project, create a class to abstract all the printing
methods into class(s) instead of having the code reside in the main code block. This will help
with code reusability and will also save you time in the long run from having to find one line
of code in the main code. By having StarIO only reside in the class(s), you will be fully taking
advantage of object oriented programming.
TIP #2: Know what the differences and definitions of (ASCII & Unicode), (Hex & Decimal), and
(Byte & Char) are. A byte is normally 8-bits long which would be 8 digits of binary (1s and 0s).
These bytes are just 8 bits of binary data but bytes can also be int or char. The three
different variable types basically hold the data in the same way but there are slight
differences. Try to code with Bytes instead of Chars, ints, or strings when choosing a variable
to contain your print job data. ASCII to Unicode and vice versa conversions are sometimes
unsecure so make sure you know what and how the encoding class works with these. Big
mistakes made in Unicode are culture-sensitive search and casing, surrogate pairs, combining
characters, and normalization.
TIP #3: HEX DUMP MODE! If you are debugging and your application seems to have a bug in it
use hex dump mode on the printer. This is the best way to verify what is being sent out of the
computer is being received correctly. To put the printer in hex dump mode, turn the printer
off, open the cover to the paper, hold the feed button down, turn the printer back on, close
the cover, let go of the feed button. Hex dump mode is a sure fire way to verify hex data is
sent correctly. When in hex dump mode, printer functions will not work.
TIP #4: Do not waste time trying to reverse engineer StarIO command codes. All the available
StarIO commands are available in the StarPRNT Command Manual and that is the best
resource to use when researching a specific StarIO command. This SDK & Manual was built to
help you (The Developer) have a very easy job ahead of you to program for Star Printers.
TIP #5: If there is a command that is not covered in this SDK but you wish to see a code
snippet of that command in use then visit our Developers section for a possible code block
that matches your needs.
TIP #6: Looking for an iOS printing SDK? Visit our Developers section to get access to Star
developer tools for these environments.
70
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
Additional Resources
This section will share resources that will help you develop good software with StarIO.
Please get the programmers manual for Star Portable Printers from the link below.
Unicode.org
1D Barcodes
2D Barcodes
Code Pages
71
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
ASCII Hex Symbol ASCII Hex Symbol ASCII Hex Symbol ASCII Hex Symbol
ASCII Hex Symbol ASCII Hex Symbol ASCII Hex Symbol ASCII Hex Symbol
64 40 @ 80 50 P 96 60 ` 112 70 p
65 41 A 81 51 Q 97 61 a 113 71 q
66 42 B 82 52 R 98 62 b 114 72 r
67 43 C 83 53 S 99 63 c 115 73 s
68 44 D 84 54 T 100 64 d 116 74 t
69 45 E 85 55 U 101 65 e 117 75 u
70 46 F 86 56 V 102 66 f 118 76 v
71 47 G 87 57 W 103 67 g 119 77 w
72 48 H 88 58 X 104 68 h 120 78 x
73 49 I 89 59 Y 105 69 i 121 79 y
74 4A J 90 5A Z 106 6A j 122 7A z
75 4B K 91 5B [ 107 6B k 123 7B {
76 4C L 92 5C \ 108 6C l 124 7C |
77 4D M 93 5D ] 109 6D m 125 7D }
78 4E N 94 5E ^ 110 6E n 126 7E ~
79 4F O 95 5F _ 111 6F o 127 7F
72
StarIO SDK -StarPRNT Portable Printer / mPOP- for Android
SDK Package
Release Date Update
Version
Apr. 17 2015 3.14.0 - Initial Release
73
http://www.starmicronics.com/support/