3.1. SMPort

Form to communicate with a printer.


















Model/Emulation

mC-Print2 mC-Print3 mPOP FVP10 TSP100IV TSP100IIIW TSP100IIIBI TSP100IIIU TSP100ECO TSP100U TSP100GT TSP100LAN TSP650II TSP650IISK TSP700II TSP800II SM-S210i SM-S220i SM-S230i SM-T300i/T300 SM-T400i BSC10 SM-L200 SM-L300 SP700
StarPRNT StarPRNT StarPRNT StarLine StarPRNT StarGraphic StarGraphic StarGraphic StarGraphic StarGraphic StarGraphic StarGraphic StarLine StarLine StarLine StarLine StarPRNT EscPosMobile StarPRNT EscPosMobile StarPRNT EscPosMobile StarPRNT EscPosMobile StarPRNT EscPosMobile EscPos StarPRNT StarPRNT StarDotImpact

getPort

releasePort

searchPrinter

writePort

readPort

getParsedStatus

beginCheckedBlock

[i] [one]

endCheckedBlock

[1] [1]

disconnect

holdPrintTimeoutMillis

getFirmwareInformation

[2] [two]
[three]
[2]
[3]
[2]
[3]
[2]
[three]
[ii]
[3]
[ii]
[iii]
[2]
[three]
[2] [2] [2] [2] [ii]

portName

portSettings

timeoutMillis

connected

StarIOVersion

[ane]

When using SM-S220i with firmware Ver two.1 or before, the following limitation exists. When using SM-T300 with firmware Ver 2.four or earlier, the following limitation exists. You tin can confirm the completion of transmission of print data only cannot confirm the completion of printing.

[2]

When using Apple tree AirMac Limited with a USB printer, it returns an empty string.

[3]

The model proper name of TSP100IIIU, TSP100U, TSP100GT and TSP100ECO is TSP100.Information technology is impossible to become the firmware version of TSP100U, TSP100GT, TSP100ECO and TSP100LAN. Library version ii.2.7 or subsequently is required for TSP100IIILAN, TSP100IIIW and TSP100IIIU.

3.i.i. Press flow

Using the SMPort class, impress per the following process.

0-1 Near End Offline Printer Sp700

  • Examples

                            
                            var
                            command
                            :
                            [
                            UInt8
                            ]
                            =
                            [
                            0x41
                            ,
                            0x42
                            ,
                            0x43
                            ,
                            0x44
                            ,
                            0x1b
                            ,
                            0x7a
                            ,
                            0x00
                            ,
                            0x1b
                            ,
                            0x64
                            ,
                            0x02
                            ]
                            while
                            true
                            {
                            var
                            port
                            :
                            SMPort
                            do
                            {
                            // Open port
                            port
                            =
                            try
                            SMPort
                            .
                            getPort
                            (
                            portName
                            :
                            "BT:Star Micronics"
                            ,
                            portSettings
                            :
                            ""
                            ,
                            ioTimeoutMillis
                            :
                            10000
                            )
                            defer
                            {
                            // Close port
                            SMPort
                            .
                            release
                            (
                            port
                            )
                            }
                            var
                            printerStatus
                            :
                            StarPrinterStatus_2
                            =
                            StarPrinterStatus_2
                            ()
                            // Start to check the completion of printing
                            endeavour
                            port
                            .
                            beginCheckedBlock
                            (
                            starPrinterStatus
                            :
                            &
                            printerStatus
                            ,
                            level
                            :
                            2
                            )
                            if
                            printerStatus
                            .
                            offline
                            ==
                            sm_true
                            {
                            suspension
                            // The printer is offline.
                            }
                            var
                            total
                            :
                            UInt32
                            =
                            
                            while
                            total
                            <
                            UInt32
                            (
                            control
                            .
                            count
                            )
                            {
                            var
                            written
                            :
                            UInt32
                            =
                            
                            // Send print information
                            try
                            port
                            .
                            write
                            (
                            writeBuffer
                            :
                            command
                            ,
                            offset
                            :
                            total
                            ,
                            size
                            :
                            UInt32
                            (
                            command
                            .
                            count
                            )
                            -
                            total
                            ,
                            numberOfBytesWritten
                            :
                            &
                            written
                            )
                            full
                            +=
                            written
                            }
                            // Stop to check the completion of printing
                            endeavour
                            port
                            .
                            endCheckedBlock
                            (
                            starPrinterStatus
                            :
                            &
                            printerStatus
                            ,
                            level
                            :
                            2
                            )
                            if
                            printerStatus
                            .
                            offline
                            ==
                            sm_true
                            {
                            break
                            // The printer is offline.
                            }
                            // Success
                            break
                            }
                            catch
                            let
                            mistake
                            as
                            NSError
                            {
                            break
                            // Some error occurred.
                            }
                            }
                          

    Refer to Communication.swift.

iii.1.ii. endCheckedBlockTimeoutMillis

This method sets the

endCheckedBlock

method’southward timeout value [unit: ms]

If it takes a long time to print, please increase this value to permit for enough time to consummate the print job.

  • Annunciation

                          
                          open up
                          var
                          endCheckedBlockTimeoutMillis
                          :
                          UInt32
                        

Important

Default value of

endCheckedBlock

method timeout value is the timeout value designated past
StarIOPort_getPort
method. Timeout length is ten seconds if specified less than 10 seconds.

When [Data timeout function setting] is used in the portSetting parameter of the

getPort

method, it should be at least iii seconds longer than the fourth dimension specified for the data timeout function. If it is set to less than 3 seconds, it volition exist controlled internally to be 3 seconds longer automatically.

iii.1.3. holdPrintTimeoutMillis

added in version 2.8.0

Timeout value for hold print control. [unit: ms]

  • Declaration

                          
                          open
                          var
                          holdPrintTimeoutMillis
                          :
                          UInt32
                        

iii.1.4. getPort

added in version 2.6.0

Opens a port for communicating with the printer.

  • Annunciation

                          
                          open up
                          course
                          func
                          getPort
                          (
                          portName
                          :
                          String
                          !,
                          portSettings
                          :
                          String
                          !,
                          ioTimeoutMillis
                          :
                          UInt32
                          )
                          throws
                          ->
                          SMPort
                          open
                          grade
                          func
                          getPort
                          (
                          _
                          portName
                          :
                          Cord
                          !,
                          _
                          portSettings
                          :
                          Cord
                          !,
                          _
                          ioTimeoutMillis
                          :
                          UInt32
                          ,
                          _
                          error
                          :
                          NSErrorPointer
                          )
                          ->
                          SMPort
                          !
                        

  • Parameter

    Name Contents Type
    portName The printer port proper noun String
    portSettings Specifies connection setting information. String
    ioTimeoutMillis The timeout time for internal control and API (unit: millisecond) UInt32
    error

    Connection failure error information

    An mistake code is set in the code property.

    NSErrorPointer
  • Render value

    Contents Type

    SMPort object

    It returns

    nil

    if it fails to generate communication port.


    SMPort
  • Mistake code

    Value Contents
    SMStarIOResultCodeFailedError Some kind of fault occurred
    SMStarIOResultCodeInUseError Connectedness was refused by the printer (another host is connected or other reason)

Refer to

Press flow

.

  1. portName Parameter

Interface

portName

Contents

Instance

Library version

Bluetooth BT:iOS Port Name

To specify the iOS Port Proper name

“BT:Star Micronics” 2.2.3+
BT:Serial Number[i]

To specify the printer using the series number

“BT:2580217090400032” 2.4.0+
BT:Mac Accost[two]

To specify the MAC address

“BT:00:12:F3:1E:2B:72” 2.iv.0+
Bluetooth Low Energy BLE:Device Proper name

To specify the Bluetooth device name

“BLE:STAR L200-00001” 2.2.3+
BLE:MAC Address

To specify the MAC address

“BLE:00:11:62:00:00:00” ii.2.3+
Ethernet/Wireless LAN TCP:IP Address

To specify the IP accost

“TCP:192.168.ane.100” 2.2.3+
USB[3] USB:Device Proper name

To specify the iOS Port Name

“USB:TSP100” 2.2.3+
USB:Serial Number

To specify the printer using the serial number

“USB:2580217090400032” ii.iv.0+
USB/Bluetooth/LAN AutoSwitch:

Using

AutoSwitch Interface

“AutoSwitch:” 2.8.0+
[1]

But mC-Print3,mC-Print2 and mPOP are supported.

[2]

Only TSP100IIIBI is supported.

[three]

When connecting an iOS device to an mPOP via USB, use a PortName that begins with

"BT:"
. Yous cannot use a PortName that begins with

"USB:"
.

Important

With models that back up both Bluetooth and USB (Lightning), in that location is no differentiation between Bluetooth and USB, and the same behavior occurs in both cases. If the Lightning cablevision is continued while a Bluetooth connectedness is active, Bluetooth will be automatically disconnected and communication volition occur via Lightning. Nonetheless it is non necessary to change portName from

"BT"

to

"USB"

at this fourth dimension.

  • AutoSwitch Interface

    This function automatically detects ports for connecting to a printer. It detects connectable ports co-ordinate to the following order of priority.

    1. USB
    2. Bluetooth
    3. LAN

    The procedure for this part is as follow.

    1. Gear up an environment so that iOS Device tin be continued with the printer via Bluetooth or LAN.

      • Pair iOS Device with the printer via Bluetooth.
      • Connect iOS Device and the printer to the same network (same segment).
    2. Connect iOS Device with the printer via USB.

    3. Specify “AutoSwitch:” for portName, and and then execute this method.

    4. If iOS Device is successfully connected with the printer via USB, Stride 3 is succeeded. If not, check the USB connexion of iOS Device and the printer, and and so endeavor Pace 3 again.

    5. Specifying “AutoSwitch:” for portName can assistance iOS Device automatically connect using other interfaces even if it is non connected with the printer via USB.

    If you want to change the printer to utilize, first over from Footstep ane.

    We recommend using this function in the post-obit cases.

    • When you can gear up an environment so that multiple interfaces including USB can be used.
    • When the connected interface is frequently changed during operation.
    • When y’all do not want to know the continued port in the program.

    Important

    • Enable the USB serial number setting for the printer.
    • Practise non perform the USB connection and Bleutooth pairing with any other printers except for the connected printer.
    • If using a LAN interface, prepare the environment then that UDP port 22222 can be used.

    Warning

    • This function may require more fourth dimension until y’all tin can kickoff printing than specifying a port directly.

    Following models back up this function.

    Model

    Firmware version

    mC-Print2 1.0+
    mC-Print3 1.0+

    Alert

    • Not support MCP20/MCP30

  1. portSettings Parameter

    The portSettings string is specified using the format shown below.

    The identifier that should be used with that model + option specification strings delimited by ‘;’.

    The identifier that should exist used with each model is as shown below.

    Model

    Emulation

    Identifier

    mC-Print2 StarPRNT “”
    mC-Print3 StarPRNT “”
    mPOP StarPRNT “”
    FVP10 StarLine “”
    TSP100IV StarPRNT “”
    TSP100IIIW StarGraphic “”
    TSP100IIIBI StarGraphic “”
    TSP100IIIU StarGraphic “”
    TSP100IIU+ StarGraphic “”
    TSP100ECO StarGraphic “”
    TSP100U StarGraphic “”
    TSP100GT StarGraphic “”
    TSP100LAN StarGraphic “”
    TSP650II StarLine “”
    TSP650IISK StarLine “”
    TSP700II StarLine “”
    TSP800II StarLine “”
    SM-S210i StarPRNT “Portable”
    EscPosMobile “Portable;escpos” or “mini”
    SM-S220i StarPRNT “Portable”
    EscPosMobile “Portable;escpos” or “mini”
    SM-S230i StarPRNT “Portable”
    EscPosMobile “Portable;escpos” or “mini”
    SM-T300i/T300 StarPRNT “Portable”
    EscPosMobile “Portable;escpos” or “mini”
    SM-T400i StarPRNT “Portable”
    EscPosMobile “Portable;escpos” or “mini”
    BSC10 EscPos “escpos”
    SM-L200 StarPRNT “Portable”
    SM-L300 StarPRNT “Portable”
    SP700 StarDotImpact “”

    The choice specification strings are shown below.

    Interface

    Pick blazon

    Contents

    Example

    Library version

    Bluetooth

    d[value]

    Data timeout function timeout value setting.

    If the d option is not specified with a model that supports the data timeout function, the data timeout role is enabled and the timeout value is prepare to 3 seconds.

    The method for specifying the timeout time is the following.

    1. If a value from 1 to 255 was specified for [value]: Fourth dimension that was specified for [value]
    2. If 0 was specified for [value] : Information timeout function is ignored
    3. Other than the above: three seconds
    “d10” ii.2.3+
    Ethernet/Wireless LAN

    l[value](lower case “50”)

    Connection retry will exist performed when the target printer is in use by another host.

    The method for specifying the retry time is the following.

    1. If a value will not be specified (“l” but) : Timeout time specified past the getPort
    2. If a value from 0 to 300000 was specified for [value]: Time that was specified for [value] (units: milliseconds).
    3. If a value of 300001 or more was specified for [value] : Timeout fourth dimension specified past the getPort
    4. Other than the above: Retry is not performed.
    “l10000” 2.four.0+
    [Port number]

    Port number(But when using Airdrome)

    “9100” 2.ii.3+
    • Data timeout role

      The data timeout function is a office which ignores the remaining impress data when data was not sent to the printer inside the specified length of time during printing.

      This function prevents corruption of the next print contents after the Bluetooth connection was disconnected during data sending.

      For usable models, refer to below.

      Model Firmware version
      mC-Print2 1.0+
      mC-Print3 1.0+
      mPOP i.0+
      FVP10 2.0+
      TSP100IIIBI 1.0+
      TSP650II 2.0+
      TSP650IISK 1.0+
      TSP700II 5.0+
      TSP800II two.0+
    • Example of portSettings

    Printer connection environment portSettings
    Uses TSP650II as the default setting. “”
    Uses mC-Print3 with retry enabled by Ethernet interface. “;l10000”
    Uses SM-L200 equally the default setting “Portable”
    If data is not sent for 10 seconds during printing withTSP650II, information technology operates the information canceling part. “;d10”
  1. ioTimeoutMillis Parameter

    timeout is a ioTimeoutMillis timeout controlled internally and is used for communication in the APIs This parameter guarantees that all of the below APIs will consummate in a bounded corporeality of time, but does Non guarantee the verbal timeout length.

    Timeout length is 10 seconds if specified less than 10 seconds.

    .

  1. Use share printer function with Apple tree AirPort Express

    Set Airdrome Express IP Address for portName.

    Ex.

    TCP:192.168.one.2

    Set up port number for portSettings.

    Increase the port number in sequential order from

    9100

    to

    9109

    until advice is successful.

  1. Notification in case of SM-L Series

    Information technology could accept some time when an iOS Device tries to connect to a printer via “Bluetooth Low Free energy”. If the connection fails, retry until the connection is successful.

    If the connection time must be reduced, please blueprint your application as the connection to a printer always keeps opening.

    In this case, the printer cannot exist detected by any other applications and iOS Device .

iii.1.5. releasePort

Closes a port for communicating with the printer.

  • Declaration

                          
                          open up
                          grade
                          func
                          release
                          (
                          _
                          port
                          :
                          SMPort
                          !)
                        

  • Parameter

    Name Contents Type
    port A SMPort object previously created by the

    getPort

    method

    SMPort
  • Return value

    None

Refer to

Printing flow

.

Alarm

After executing getPort, please practise non forget releasePort before executing the next getPort. Otherwise the advice may return

nil

.

3.1.6. searchPrinter

added in version 2.6.0

Search the Star printer and return search results.

  • Announcement

                          
                          open
                          class
                          func
                          searchPrinter
                          (
                          target
                          :
                          String
                          !)
                          throws
                          ->
                          [
                          Whatever
                          ]
                          open
                          class
                          func
                          searchPrinter
                          (
                          _
                          target
                          :
                          Cord
                          !,
                          _
                          error
                          :
                          NSErrorPointer
                          )
                          ->
                          [
                          Any
                          ]
                          !
                        

  • Parameter

    Name Contents Type
    target

    All interface types:

    "All:"

    Bluetooth:

    "BT:"

    Bluetooth Low Energy:

    "BLE:"

    Ethernet/Wireless LAN:

    "TCP:"

    USB:

    "USB:"

    String
    mistake

    Connection failure mistake information

    An error code is set in the code property.

    NSErrorPointer
  • Return value

    Contents Type

    Search issue of Star printer

    Refer to

    PortInfo

    form.

    [Any]
  • Error lawmaking

    Value Contents
    SMStarIOResultCodeFailedError Some kind of mistake occurred.
  • Examples

                            
                            var
                            searchPrinterResult
                            :
                            [
                            PortInfo
                            ]?
                            =
                            nada
                            do
                            {
                            searchPrinterResult
                            =
                            try
                            SMPort
                            .
                            searchPrinter
                            (
                            target
                            :
                            "ALL:"
                            )
                            every bit
                            ?
                            [
                            PortInfo
                            ]
                            }
                            grab
                            {
                            // Some mistake occurred.
                            }
                            guard
                            let
                            portInfoArray
                            :
                            [
                            PortInfo
                            ]
                            =
                            searchPrinterResult
                            else
                            {
                            return
                            }
                            for
                            portInfo
                            :
                            PortInfo
                            in
                            portInfoArray
                            {
                            print
                            (
                            "Port Name:
                            
                            \(
                            portInfo
                            .
                            portName
                            ??
                            ""
                            )
                            "
                            )
                            impress
                            (
                            "MAC Address:
                            
                            \(
                            portInfo
                            .
                            macAddress
                            ??
                            ""
                            )
                            "
                            )
                            impress
                            (
                            "Model Proper noun:
                            
                            \(
                            portInfo
                            .
                            modelName
                            ??
                            ""
                            )
                            "
                            )
                            }
                          

    Refer to SearchPortViewController.swift.

Important

  • This API do not guarantee the discovery of devices.
  • With models that support both Bluetooth and USB (Lightning), there is no differentiation between Bluetooth and USB. Regardless of the bodily connexion method, when a target is non specified or when

    "BT:"

    is specified, the printer is detected as a Bluetooth printer, and when

    "USB"

    is specified information technology is detected every bit a USB printer.
  • When using Bluetooth Low Energy interface and getting the printer device name past searchPriner method for the beginning time, sometimes portName will exist

    "BLE:"

    .In those cases, please connect the printer using

    getPort

    method. Once you have got the Device name, searchPrinter method works correctly.
  • When an iOS device and an mPOP are connected via USB, the mPOP is detected as a Bluetooth connexion (e.yard.,

    "BT:mPOP"
    ). Therefore, please specify

    "BT:"

    or

    "All:"

    for target.

3.1.7. writePort

added in version 2.6.0

Write data to the printer.

  • Declaration

                          
                          open
                          func
                          write
                          (
                          writeBuffer
                          :
                          UnsafePointer
                          <
                          UInt8
                          >
                          !
                          ,
                          start
                          :
                          UInt32
                          ,
                          size
                          :
                          UInt32
                          ,
                          numberOfBytesWritten
                          :
                          UnsafeMutablePointer
                          <
                          UInt32
                          >
                          !
                          )
                          throws
                          open up
                          func
                          write
                          (
                          _
                          writeBuffer
                          :
                          UnsafePointer
                          <
                          UInt8
                          >
                          !
                          ,
                          _
                          offSet
                          :
                          UInt32
                          ,
                          _
                          size
                          :
                          UInt32
                          ,
                          _
                          error
                          :
                          NSErrorPointer
                          )
                          ->
                          UInt32
                        

  • Parameter

    Proper noun Contents Type
    writeBuffer Contains the output data in a byte array UnsafePointer<UInt8>
    offset Specifies where to begin pulling data from writeBuffer. UInt32
    size Number of bytes to write UInt32
    numberOfBytesWritten

    Bluetooth/Ethernet/Wireless LAN/USB I/F

    The number of bytes that were actually written.

    This method is successful even when all of the information cannot exist written. Your application should call this function a limited number of times until all the data has been written out or until an application adamant retry threshold has been reached.

    Bluetooth Low Free energy I/F

    It returns a manual data size when it succeeded and “0” when it failed.

    UnsafeMutablePointer<UInt32>
    mistake

    Connection failure error data

    An error code is set in the code property.

    NSErrorPointer
  • Render value

    Contents Type

    Bluetooth/Ethernet/Wireless LAN/USB I/F

    The number of bytes that were actually written.

    This method is successful even when all of the data cannot be written. Your awarding should call this office a limited number of times until all the data has been written out or until an application determined retry threshold has been reached.

    Bluetooth Low Free energy I/F

    It returns a transmission data size when it succeeded and “0” when it failed.

    UInt32
  • Error code

    Value Contents
    SMStarIOResultCodeFailedError Some kind of mistake occurred.

Refer to

Press flow

.

3.one.viii. readPort

added in version 2.half dozen.0

Read data from the printer. Please use it simply when it is necessary to read Raw byte from the printer.

  • Declaration

                          
                          open
                          func
                          read
                          (
                          readBuffer
                          :
                          UnsafeMutablePointer
                          <
                          UInt8
                          >
                          !
                          ,
                          showtime
                          :
                          UInt32
                          ,
                          size
                          :
                          UInt32
                          ,
                          numberOfBytesRead
                          :
                          UnsafeMutablePointer
                          <
                          UInt32
                          >
                          !
                          )
                          throws
                          open up
                          func
                          read
                          (
                          _
                          readBuffer
                          :
                          UnsafeMutablePointer
                          <
                          UInt8
                          >
                          !
                          ,
                          _
                          offSet
                          :
                          UInt32
                          ,
                          _
                          size
                          :
                          UInt32
                          ,
                          _
                          fault
                          :
                          NSErrorPointer
                          )
                          ->
                          UInt32
                        

  • Parameter

    Name Contents Type
    readBuffer A Byte Array buffer into which data is read. UnsafeMutablePointer<UInt8>
    offset specifies where to begin writing data into the readBuffer UInt32
    size Full number of bytes to read UInt32
    numberOfBytesRead

    The number of bytes that were read

    This method will succeed fifty-fifty when no all data was read in. Your application should call this office a limited number of times until the expected information has been read in or until an application determined retry threshold has been reached.

    UnsafeMutablePointer<UInt32>
    error

    Connectedness failure error information

    An error code is prepare in the code holding.

    NSErrorPointer
  • Render value

    Contents Type

    The number of bytes that were read

    This method will succeed even when no all data was read in. Your application should phone 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.

    UInt32
  • Fault code

    Value Contents
    SMStarIOResultCodeFailedError Some kind of error occurred.

Important

Beginning from StarIO.framework v2.4.0 (StarPRNT SDK v5.6.0), the readPort behavior when a LAN printer is used has been changed every bit shown beneath.

When the information that should be received when readPort is executed does not exist
  • v2.3.3 and before: Throws a

    PortException

    .
  • v2.iv.0 and later: Returns



    .

3.1.ix. getParsedStatus

added in version 2.6.0

Become printer status.

  • Declaration

                          
                          open
                          func
                          getParsedStatus
                          (
                          starPrinterStatus
                          :
                          UnsafeMutableRawPointer
                          !,
                          level
                          :
                          UInt32
                          )
                          throws
                          open
                          func
                          getParsedStatus
                          (
                          _
                          starPrinterStatus
                          :
                          UnsafeMutableRawPointer
                          !,
                          _
                          level
                          :
                          UInt32
                          ,
                          _
                          error
                          :
                          NSErrorPointer
                          )
                          ->
                          UInt32
                        

  • Parameter

    Proper name Contents Type
    starPrinterStatus

    Giving the current device status.

    For the type of condition that tin can be obtained, refer to the

    StarPrinterStatus

    structure.

    UnsafeMutableRawPointer
    level

    StarPrinterStatus structure level

    (Possible to specify a value of 0, 1 or 2. Unremarkably two is specified.)

    UInt32
    error

    Connection failure error information

    An mistake code is prepare in the code belongings.

    NSErrorPointer
  • Return value

    Contents Type

    Successful:

    ane

    Failure:


    UInt32
  • Mistake lawmaking

    Value Contents
    SMStarIOResultCodeFailedError Some kind of mistake occurred.
  • Examples

                            
                            var
                            printerStatus
                            :
                            StarPrinterStatus_2
                            =
                            StarPrinterStatus_2
                            ()
                            do
                            {
                            try
                            port
                            .
                            getParsedStatus
                            (
                            starPrinterStatus
                            :
                            &
                            printerStatus
                            ,
                            level
                            :
                            2
                            )
                            }
                            catch
                            {
                            // Some mistake occurred.
                            }
                            if
                            printerStatus
                            .
                            offline
                            ==
                            sm_true
                            {
                            if
                            printerStatus
                            .
                            coverOpen
                            ==
                            sm_true
                            {
                            // Embrace is open.
                            }
                            else
                            if
                            printerStatus
                            .
                            receiptPaperEmpty
                            ==
                            sm_true
                            {
                            // Receipt paper is empty.
                            }
                            else
                            {
                            // The printer is offline.
                            }
                            }
                            else
                            {
                            // The printer is online.
                            }
                          

    Refer to DeviceStatusViewController.swift.

3.1.ten. beginCheckedBlock

added in version ii.6.0

This method is used in combination with

endCheckedBlock

and checks the completion of printing.

To bank check if the whole data is completely printed, you need to run this method merely earlier sending print data and

endCheckedBlock

but after sending print information.

When the control of hold print control is enabled, this method blocks until the newspaper is removed, and returns control to the awarding when it is removed. If paper is not removed within the timeout specified past the

holdPrintTimeoutMillis
, the error is occured.

  • Announcement

                          
                          open up
                          func
                          beginCheckedBlock
                          (
                          starPrinterStatus
                          :
                          UnsafeMutableRawPointer
                          !,
                          level
                          :
                          UInt32
                          )
                          throws
                          open up
                          func
                          beginCheckedBlock
                          (
                          _
                          starPrinterStatus
                          :
                          UnsafeMutableRawPointer
                          !,
                          _
                          level
                          :
                          UInt32
                          ,
                          _
                          mistake
                          :
                          NSErrorPointer
                          )
                          ->
                          UInt32
                        

  • Parameter

    Name Contents Blazon
    starPrinterStatus

    A pointer to StarPrinterStatus structure

    (Possible to specify StarPrinterStatus, StarPrinterStatus_1 of StarPrinterStatus_2. Normally StarPrinterStatus_2 is specified.)

    When this method is successful, the status of the current printer is stored.

    UnsafeMutableRawPointer
    level

    StarPrinterStatus structure level

    (Possible to specify a value of 0, 1 or 2. Normally ii is specified.)

    UInt32
    mistake

    Connection failure mistake information

    An fault code is ready in the code belongings.

    NSErrorPointer
  • Return value

    Contents Blazon

    Successful:

    1

    Failure:


    UInt32
  • Error lawmaking

    Value

    Contents

    Library version

    SMStarIOResultCodePaperPresentError

    Paper was not removed within the timeout.

    2.eight.0+

    SMStarIOResultCodeFailedError

    Some kind of error occurred.

    2.2.3+

  • Examples

    Refer to

    Press flow

    virtually the procedure of the print terminate monitoring procedure past beginCheckedBlock / endCheckedBlock.

3.1.eleven. endCheckedBlock

added in version two.vi.0

This method is used together with the

beginCheckedBlock

method every bit a pair.

This method monitors printer status and when the transferred data is printed completely or when the printer status is offline during printing or when occurs the timeout specified by the
endCheckedBlockTimeoutMillis

, it returns control to the application.

  • Proclamation

                          
                          open
                          func
                          endCheckedBlock
                          (
                          starPrinterStatus
                          :
                          UnsafeMutableRawPointer
                          !,
                          level
                          :
                          UInt32
                          )
                          throws
                          open up
                          func
                          endCheckedBlock
                          (
                          _
                          starPrinterStatus
                          :
                          UnsafeMutableRawPointer
                          !,
                          _
                          level
                          :
                          UInt32
                          ,
                          _
                          fault
                          :
                          NSErrorPointer
                          )
                          ->
                          UInt32
                        

  • Parameter

    Proper name Contents Blazon
    starPrinterStatus

    A pointer to StarPrinterStatus structure

    (Possible to specify StarPrinterStatus, StarPrinterStatus_1 of StarPrinterStatus_2. Normally StarPrinterStatus_2 is specified.)

    When this method is successful, the status of the electric current printer is stored.

    UnsafeMutableRawPointer
    level

    StarPrinterStatus structure level

    (Possible to specify a value of 0, 1 or 2. Normally ii is specified.)

    UInt32
    mistake

    Connection failure error information

    An error lawmaking is set in the lawmaking belongings.

    NSError **
  • Return value

    Contents Blazon

    Successful:

    1

    Failure:


    UInt32
  • Error code

    Value Contents
    SMStarIOResultCodeFailedError Some kind of fault occurred.
  • Examples

    Refer to

    Press flow

    almost the procedure of the impress end monitoring process by beginCheckedBlock / endCheckedBlock.

3.one.12. disconnect

added in version 2.6.0

Disconnects the specified Bluetooth device.

After the disconnection, the Bluetooth device can be connected by other iOS Device .

  • Declaration

                          
                          open
                          func
                          disconnectAccessory
                          ()
                          throws
                          open up
                          func
                          disconnect
                          (
                          _
                          error
                          :
                          NSErrorPointer
                          )
                          ->
                          Bool
                        

  • Parameter

    Proper noun Contents Type
    fault

    Connexion failure fault data

    An fault code is set in the lawmaking belongings.

    NSErrorPointer
  • Return value

    Contents Type

    Disconnect success and neglect

    This method fails in the post-obit cases:

    * when the disconnection has non been completed inside the timeout specified by getPort

    * when the disconnection part is non supported by a printer (such like portable printers).

    This method has no issue on Ethernet devices.

    It always returns true when it was run with the Ethernet device.

    Bool
  • Mistake code

    Value Contents
    SMStarIOResultCodeFailedError Some kind of fault occurred.

3.ane.thirteen. getFirmwareInformation

added in version 2.half-dozen.0

Gets printer model name and firmware version.

  • Declaration

                          
                          open
                          func
                          getFirmwareInformation
                          ()
                          throws
                          ->
                          [
                          AnyHashable
                          :
                          Any
                          ]
                          open up
                          func
                          getFirmwareInformation
                          (
                          _
                          error
                          :
                          NSErrorPointer
                          )
                          ->
                          [
                          AnyHashable
                          :
                          Any
                          ]
                          !
                        

  • Parameter

    Name Contents Blazon
    error

    Connection failure mistake data

    An error code is set in the lawmaking holding.

    NSErrorPointer
  • Return value

    Contents Type

    An acquisition outcome of firmware information

    The return value can go the model name by setting the Dictionary object central of the return value to

    "ModelName"

    and go the firmware version by setting

    "FirmwareVersion"

    .

    [AnyHashable: Whatever]
  • Error code

    Value Contents
    SMStarIOResultCodeFailedError Some kind of error occurred.

three.1.14. portName

Go the portName when the port is opened.

  • Declaration

                          
                          open up
                          func
                          portName
                          ()
                          ->
                          String
                          !
                        

3.1.xv. portSettings

Become the portSettings when the port is opened.

  • Declaration

                          
                          open
                          func
                          portSettings
                          ()
                          ->
                          String
                          !
                        

iii.ane.sixteen. timeoutMillis

Go the portSettings specified by

getPort

method.

  • Declaration

                          
                          open
                          func
                          timeoutMillis
                          ()
                          ->
                          UInt32
                        

3.1.17. continued

If the printer is connected to an iOS device, it returns truthful. If the printer is not connected to an iOS device, it returns simulated.

  • Declaration

                          
                          open
                          func
                          connected
                          ()
                          ->
                          Bool
                        

Important

Just Bluetooth/Bluetooth Low Energy interfaces are supported. For not-supported interfaces, information technology constantly returns true.

Due to the restrictions of the iOS device, it takes approximately 5 seconds from Bluetooth/Bluetooth Depression Energy advice disconnecting until existence reflected in this property.

3.1.xviii. StarIOVersion

Get the version number of the StarIO library.

  • Announcement

                          
                          open
                          class
                          func
                          starIOVersion
                          ()
                          ->
                          String
                          !
                        

  • Parameter

    None

  • Render value

    Contents Type
    StarIO library version String