3.5. StarBluetoothManager

Bluetoothインターフェイスの各種設定を行うためのクラスです。

警告

StarIOPort クラスと同時に使用しないでください。

  • メソッド

    名称

    説明

    open

    プリンターと通信するためのポートをオープンします。

    loadSetting

    接続したプリンターから設定を取得します。

    close

    プリンターと通信するためのポートをクローズします。

    apply

    プリンターに指定した値を設定します。

    getBluetoothDeviceNameCapability

    Bluetoothデバイス名の設定可否情報を取得します。

    getBluetoothDeviceName

    Bluetoothデバイス名を取得します。

    setBluetoothDeviceName

    Bluetoothデバイス名を設定します。

    getiOSPortNameCapability

    iOSポート名の設定可否情報を取得します。

    getiOSPortName

    iOSポート名を取得します。

    setiOSPortName

    iOSポート名を設定します。

    getPinCodeCapability

    PINコード設定可否情報を取得します。

    getPinCode

    setPinCodeメソッドで設定したPINコードを取得します。

    setPinCode

    Bluetoothペアリング時に使用するPINコードを設定します。

    getAutoConnectCapability

    AutoConnectionの設定可否情報を取得します。

    getAutoConnect

    AutoConnectionのオン/オフを取得します。

    setAutoConnect

    AutoConnectionのオン/オフを設定します。

    getSecurityTypeCapability

    Bluetoothセキュリティタイプの設定可否情報を取得します。

    getSecurityType

    Bluetoothセキュリティタイプを取得します。

    setSecurityType

    Bluetoothセキュリティタイプを設定します。

    getPortName

    コンストラクタで指定したportNameを取得します。

    getPortSettings

    コンストラクタで指定したportSettingsを取得します。

    getTimeoutMillis

    コンストラクタで指定したioTimeoutMillisを取得します。

    getDeviceType

    コンストラクタで指定したdeviceTypeを取得します。

    isOpened

    ポートの状態を取得します。

各モデルにおいて機能するメソッド/パラメータは以下のとおりです。

モデル/エミュレーション

mC-Print2 mC-Print3 mC-Label3 mPOP FVP10 TSP100IV TSP100IIIW TSP100IIIBITSP100IIIU TSP100IIU+ TSP100ECO TSP100U TSP100GTTSP100LAN TSP650II TSP650IISK TSP700II TSP800IITUP500SM-S210i SM-S220i SM-S230i SM-T300i/T300 SM-T400i BSC10 SM-L200 SM-L300 SP700SK1-211/221/V211 SK1-211/221/V211 Presenter SK1-311/321/V311 SK1-311/V311 Presenter
StarPRNT StarPRNT StarPRNT StarPRNT StarLine StarPRNT StarGraphic StarGraphic StarGraphic StarGraphic StarGraphic StarGraphic StarGraphic StarGraphic StarLine StarLine StarLine StarLine StarLine StarPRNT EscPosMobile[1] StarPRNT EscPosMobile[1] StarPRNT EscPosMobile[1] StarPRNT EscPosMobile[1] StarPRNT EscPosMobile[1] EscPos StarPRNT StarPRNT StarDotImpact StarPRNT StarPRNT StarPRNT StarPRNT

open

- - - - - - - - - - - - - -

loadSetting

- - - - - - - - - - - - - -

close

- - - - - - - - - - - - - -

apply

- - - - - - - - - - - - - -

getBluetoothDeviceNameCapability

- - - - - - - - - - - - - -

getBluetoothDeviceName

- - - - - - - - - - - - - -

setBluetoothDeviceName

- - - - - - - - - - - - - -

getiOSPortNameCapability

- - - - - - - - - - - - - -

getiOSPortName

- - - - - - - - - - - - - - - -

setiOSPortName

- - - - - - - - - - - - - - - -

getPinCodeCapability

- - - - - - - - - - - - - -

getPinCode

- - - - - - - - - - - - - - - - - - -

setPinCode

- - - - - - - - - - - - - - - - - - -

getAutoConnectCapability

- - - - - - - - - - - - - -

getAutoConnect

- - - - - - - - - - - - - - - -

setAutoConnect

- - - - - - - - - - - - - - - -

getSecurityTypeCapability

- - - - - - - - - - - - - -

getSecurityType

- - - - [2] - - - - - - - - - [2] [2] [2] [2] - [4] [4] [3] [3] [4] [4] [4] [4] [4] [4] - [3] [3] [2] - - - -

setSecurityType

- - - - [2] - - - - - - - - - [2] [2] [2] [2] - [4] [4] [3] [3] [4] [4] [4] [4] [4] [4] - [3] [3] [2] - - - -

getPortName

- - - - - - - - - - - - - -

getPortSettings

- - - - - - - - - - - - - -

getTimeoutMillis

- - - - - - - - - - - - - -

getDeviceType

- - - - - - - - - - - - - -

isOpened

- - - - - - - - - - - - - -
[1]

ファームウェアバージョン3.0以降が必要です

[2]

設定・取得できるSecurityTypeはPINコードもしくはSSP

[3]

設定・取得できるSecurityTypeはPINコードもしくはDisable

[4]
ファームウェアバージョン5.0未満 : 設定・取得できるSecurityTypeはPINコードもしくはDisable
ファームウェアバージョン5.0以降 : 設定・取得できるSecurityTypeはPINコード、SSP、SSP Numeric ComparisonもしくはDisable

3.5.1. Bluetooth設定変更フロー

StarBluetoothManagerクラスを利用し、以下の手順に沿ってプリンタのBluetooth設定を変更します。

../_images/bluetooth_flow.png
StarBluetoothManager manager = null;

try {
    // Get StarBluetoothManager
    manager = StarBluetoothManagerFactory.getManager(portName, portSettings, 10000, emulation);

    // Port open
    manager.open();

    // Loading Bluetooth settings
    manager.loadSetting();

    // Set Bluetooth settings
    // Example) When setting the device name to "Star Micronics"
    manager.setBluetoothDeviceName("Star Micronics");

    // Apply Bluetooth settings
    manager.apply();
}
catch (StarIOPortException e) {
    // Error
}
finally {
    if (manager.isOpened()) {
    try {
        // Port close
        manager.close();
    }
    catch (StarIOPortException e) {}
    }
}

BluetoothSettingFragment.java を参照ください。

3.5.2. StarDeviceType

プリンタタイプを示す定数です。

  • 宣言

    public enum StarDeviceType {
        StarDeviceTypeDesktopPrinter,
        StarDeviceTypePortablePrinter
    }
    
  • 定数

    名称

    説明

    StarDeviceTypeDesktopPrinter

    デスクトッププリンタ

    StarDeviceTypePortablePrinter

    モバイルプリンタ

各モデルに対して適用すべき定数は以下のとおりです。

モデル

エミュレーション

定数

mC-Print2 StarPRNT

StarDeviceTypePortablePrinter

mC-Print3 StarPRNT

StarDeviceTypePortablePrinter

mC-Label3 StarPRNT

StarDeviceTypePortablePrinter

mPOP StarPRNT

StarDeviceTypePortablePrinter

FVP10 StarLine

StarDeviceTypeDesktopPrinter

TSP100IIIBI StarGraphic

StarDeviceTypeDesktopPrinter

TSP650II StarLine

StarDeviceTypeDesktopPrinter

TSP650IISK StarLine

StarDeviceTypeDesktopPrinter

TSP700II StarLine

StarDeviceTypeDesktopPrinter

TSP800II StarLine

StarDeviceTypeDesktopPrinter

SM-S210i StarPRNT

StarDeviceTypePortablePrinter

EscPosMobile
SM-S220i StarPRNT

StarDeviceTypePortablePrinter

EscPosMobile
SM-S230i StarPRNT

StarDeviceTypePortablePrinter

EscPosMobile
SM-T300i/T300 StarPRNT

StarDeviceTypePortablePrinter

EscPosMobile
SM-T400i StarPRNT

StarDeviceTypePortablePrinter

EscPosMobile
SM-L200 StarPRNT

StarDeviceTypePortablePrinter

SM-L300 StarPRNT

StarDeviceTypePortablePrinter

SP700 StarDotImpact

StarDeviceTypeDesktopPrinter

3.5.3. StarBluetoothSecurity

Bluetoothセキュリティタイプを示す定数です。

  • 宣言

    public enum StarBluetoothSecurity {
        PINCODE,
        SSP,
        SSP_NUMERIC_COMPARISON,
        DISABLE
    }
    
  • 定数

    名称

    説明

    PINCODE

    PINコード入力によるセキュリティ

    SSP

    インターフェイスカード搭載機種:ボタン押下によるセキュリティ
    それ以外:追加操作なし

    SSP_NUMERIC_COMPARISON

    プリンターのディスプレイに表示された認証コード、もしくはプリンターから印刷された認証コードとの一致を確認

    DISABLE

    セキュリティなし

3.5.4. StarBluetoothSettingCapability

Bluetooth設定可否を示す定数です。

  • 宣言

    public enum StarBluetoothSecurity {
        SUPPORT,
        NOSUPPORT
    }
    
  • 定数

    名称

    説明

    SUPPORT

    現在接続中のプリンタではその項目・機能が設定できることを示します。

    NOSUPPORT

    現在接続中のプリンタではその項目・機能が設定できないことを示します。

3.5.5. StarBluetoothManager

インスタンスを生成します。

  • 宣言

    StarBluetoothManager(String portName, String portSetting, int ioTimeoutMillis, StarBluetoothManager.StarDeviceType starDeviceType);
    
  • 引数

    引数

    説明

    portName

    getPort メソッドのportNameと同じです。

    String

    portSettings

    getPort メソッドのportSettingと同じです。

    String

    ioTimeoutMillis

    内部制御および各APIのタイムアウト値

    int

    starDeviceType

    プリンタータイプ定数

    StarDeviceType

    各モデルに対して設定するstarDeviceType引数の値は、 StarDeviceType 定数を参照ください。

  • 戻り値

    説明

    StarBluetoothManager オブジェクト

    StarBluetoothManager

Bluetooth設定変更の手順は、 Bluetooth設定変更フロー を参照ください。

注釈

starioextension.aar に含まれる StarBluetoothManagerFactory では、プリンタのエミュレーションに対して適切な StarBluetoothManager オブジェクトを取得することができます。

3.5.6. open

プリンターと通信するためのポートをオープンします。

重要

本メソッド実行後は、必ず loadSetting メソッドを実行し現在の設定を取得してください。

  • 宣言

    public void open();
    
  • 引数

    なし

  • 戻り値

    なし

Bluetooth設定変更の手順は、 Bluetooth設定変更フロー を参照ください。

3.5.7. loadSetting

接続したプリンターから設定を取得します。

  • 宣言

    public void loadSetting();
    
  • 引数

    なし

  • 戻り値

    なし

Bluetooth設定変更の手順は、 Bluetooth設定変更フロー を参照ください。

3.5.8. close

プリンターと通信するためのポートをクローズします。

  • 宣言

    public void close();
    
  • 引数

    なし

  • 戻り値

    なし

Bluetooth設定変更の手順は、 Bluetooth設定変更フロー を参照ください。

3.5.9. apply

以下メンバーで指定した値をプリンターに設定します。

  • 宣言

    public void apply();
    
  • 引数

    なし

  • 戻り値

    なし

Bluetooth設定変更の手順は、 Bluetooth設定変更フロー を参照ください。

3.5.10. getBluetoothDeviceNameCapability

Bluetoothデバイス名の設定可否情報を示します。

  • 宣言

    public StarBluetoothManager.StarBluetoothSettingCapability getBluetoothDeviceNameCapability();
    
  • 引数

    なし

3.5.11. getBluetoothDeviceName

Bluetoothデバイス名を示します。

  • 宣言

    public String getBluetoothDeviceName();
    
  • 引数

    なし

  • 戻り値

    説明

    Bluetoothデバイス名

    String

3.5.12. setBluetoothDeviceName

Bluetoothデバイス名を設定します。

Bluetoothデバイス名を変更するには、本メソッド後に apply メソッドを実行してください。

  • 宣言

    public void setBluetoothDeviceName(String bluetoothDeviceName);
    
  • 引数

    名称

    説明

    bluetoothDeviceName

    Bluetoothデバイス名

    String

  • 戻り値

    なし

  • 例外

    説明

    使用可能文字以外を含む文字列を設定したとき
    文字数制限を満たさない文字列を設定したとき

    StarIOPortException

  1. 使用可能文字

    0-9 a-z A-Z ; : ! ? # $ % & , . @ _ - = Space / * + ~ ^ [ { ( ] } ) | \

  2. 文字数制限

    1文字以上 かつ 16文字以下

3.5.13. getiOSPortNameCapability

iOSポート名の設定可否情報を示します。

  • 宣言

    public StarBluetoothManager.StarBluetoothSettingCapability getiOSPortName();
    
  • 引数

    なし

3.5.14. getiOSPortName

iOSポート名を示します。

  • 宣言

    public String getiOSPortName();
    
  • 引数

    なし

  • 戻り値

    説明

    iOSポート名

    String

3.5.15. setiOSPortName

iOSポート名を設定します。

iOSポート名を変更するには、本メソッド後に apply メソッドを実行してください。

  • 宣言

    public void setiOSPortName(String iOSPortName);
    
  • 引数

    名称

    説明

    iOSPortName

    iOSポート名

    String

  • 戻り値

    なし

  • 例外

    説明

    使用可能文字以外を含む文字列を設定したとき
    文字数制限を満たさない文字列を設定したとき

    StarIOPortException

  1. 使用可能文字

    0-9 a-z A-Z ; : ! ? # $ % & , . @ _ - = Space / * + ~ ^ [ { ( ] } ) | \

  2. 文字数制限

    1文字以上 かつ 16文字以下

3.5.16. getPinCodeCapability

PINコード設定可否情報を示します。

  • 宣言

    public StarBluetoothManager.StarBluetoothSettingCapability getPinCodeCapability();
    
  • 引数

    なし

3.5.17. getPinCode

Bluetoothペアリング時に使用するPINコードを示します。

  • 宣言

    public String getPinCode();
    
  • 引数

    なし

  • 戻り値

    説明

    PINコード

    String

3.5.18. setPinCode

Bluetoothペアリング時に使用するPINコードを設定します。

PINコードを変更するには、本メソッド後に apply メソッドをを実行してください。

  • 宣言

    public void setPinCode(String pinCode);
    
  • 引数

    名称

    説明

    pinCode

    PINコード

    String

  • 戻り値

    なし

  • 例外

    説明

    使用可能文字以外を含む文字列を設定したとき
    文字数制限を満たさない文字列を設定したとき

    StarIOPortException

  1. 使用可能文字

    • 0-9 (SM-L200、SM-L300)

    • 0-9 a-z A-Z (その他のモデル)

  2. 文字数制限

    • 4文字 (SM-L200、SM-L300)

    • 4文字以上 かつ 16文字以下(その他のモデル)

3.5.19. getAutoConnectCapability

AutoConnectionの設定可否情報を示します。

  • 宣言

    public StarBluetoothManager.StarBluetoothSettingCapability getAutoConnectCapability();
    
  • 引数

    なし

3.5.20. getAutoConnect

AutoConnection(自動接続機能)のオン/オフを示します。

  • 宣言

    public boolean getAutoConnect();
    
  • 引数

    なし

  • 戻り値

    説明

    AutoConnection設定
    true ... AutoConnection設定がオン
    false ... AutoConnection設定がオフ

    boolean

3.5.21. setAutoConnect

AutoConnectionを設定します。

AutoConnectionの設定を変更するには、本メソッド後に apply メソッドを実行してください。

  • 宣言

    public void setAutoConnect(boolean autoConnect);
    
  • 引数

    名称

    説明

    autoConnect

    AutoConnection設定
    true ... AutoConnection設定をオンにする
    false ... AutoConnection設定をオフにする

    boolean

  • 戻り値

    なし

3.5.22. getSecurityTypeCapability

Bluetoothセキュリティタイプの設定可否情報を示します。

  • 宣言

    public StarBluetoothManager.StarBluetoothSettingCapability getSecurityTypeCapability();
    
  • 引数

    なし

3.5.23. getSecurityType

Bluetoothセキュリティタイプを示します。

  • 宣言

    public StarBluetoothManager.StarBluetoothSecurity getSecurityType();
    
  • 引数

    なし

3.5.24. setSecurityType

セキュリティタイプを設定します。

セキュリティタイプを変更するには、本メソッド後に apply メソッドを実行してください。

  • 宣言

    public void setSecurityType(StarBluetoothManager.StarBluetoothSecurity securityType);
    
  • 引数

    名称

    説明

    securityType

    Bluetoothセキュリティタイプ

    StarBluetoothSecurity

  • 戻り値

    なし

3.5.25. getPortName

コンストラクタで指定したportNameを取得します。

  • 宣言

    public String getPortName();
    
  • 引数

    なし

  • 戻り値

    説明

    コンストラクタで指定したportName

    String

3.5.26. getPortSettings

コンストラクタで指定したportSettingsを取得します。

  • 宣言

    public String getPortSettings();
    
  • 引数

    なし

  • 戻り値

    説明

    コンストラクタで指定したportSettings

    String

3.5.27. getTimeoutMillis

コンストラクタで指定したioTimeoutMillisを取得します。

  • 宣言

    public int getTimeoutMillis();
    
  • 引数

    なし

  • 戻り値

    説明

    コンストラクタで指定したioTimeoutMillis

    int

3.5.28. getDeviceType

接続先プリンタの種類を示します。

  • 宣言

    public StarBluetoothManager.StarDeviceType getDeviceType();
    
  • 引数

    なし

  • 戻り値

    説明

    コンストラクタで指定したdeviceType

    StarDeviceType

3.5.29. isOpened

ポートがオープンされているかどうかを示します。

  • 宣言

    public boolean isOpened();
    
  • 引数

    なし

  • 戻り値

    説明

    ポートの状態
    true ... ポートがオープンされている
    false ... ポートがクローズされている

    boolean