3.4. SMBluetoothManager¶
Bluetoothインターフェイスの各種設定を行うためのクラスです。
警告
SMPort クラスと同時に使用しないでください。
列挙体
名称
説明
プリンタタイプ定数
Bluetoothセキュリティタイプ定数
Bluetooth設定可否定数
コンストラクタ
名称
説明
インスタンスを生成します。
プロパティ
名称
説明
コンストラクタで指定したportNameを取得します。
接続先プリンターの種類
ポートが開いているかどうか
Bluetoothデバイス名
iOSポート名
AutoConnection
Bluetoothセキュリティタイプ
Bluetoothペアリング時に使用するPINコード
Bluetoothデバイス名の設定可否情報
iOSポート名の設定可否情報
AutoConnectionの設定可否情報
Bluetoothセキュリティタイプの設定可否情報
PINコード設定可否情報
メソッド
名称
説明
プリンターと通信するためのポートをオープンします。
接続したプリンターから設定を取得します。
プリンターと通信するためのポートをクローズします。
プリンターに指定した値を設定します。
各モデルにおいて機能するメソッド/パラメータは以下のとおりです。
モデル/エミュレーション |
mC-Print2 | mC-Print3 | mPOP | FVP10 | TSP100IV | TSP100IIIW | TSP100IIIBI | TSP100IIIU | TSP100IIU+ | 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 | StarGraphic | StarLine | StarLine | StarLine | StarLine | StarPRNT | EscPosMobile[1] | StarPRNT | EscPosMobile[1] | StarPRNT | EscPosMobile[1] | StarPRNT | EscPosMobile[1] | StarPRNT | EscPosMobile[1] | EscPos | StarPRNT | StarPRNT | StarDotImpact | |
open |
✔ | ✔ | ✔ | ✔ | - | - | ✔ | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | - | ✔ | ✔ | ✔ |
loadSetting |
✔ | ✔ | ✔ | ✔ | - | - | ✔ | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | - | ✔ | ✔ | ✔ |
close |
✔ | ✔ | ✔ | ✔ | - | - | ✔ | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | - | ✔ | ✔ | ✔ |
apply |
✔ | ✔ | ✔ | ✔ | - | - | ✔ | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | - | ✔ | ✔ | ✔ |
deviceNameCapability |
✔ | ✔ | ✔ | ✔ | - | - | ✔ | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | - | ✔ | ✔ | ✔ |
deviceName |
✔ | ✔ | ✔ | ✔ | - | - | ✔ | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | - | ✔ | ✔ | ✔ |
iOSPortNameCapability |
✔ | ✔ | ✔ | ✔ | - | - | ✔ | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | - | ✔ | ✔ | ✔ |
iOSPortName |
✔ | ✔ | ✔ | ✔ | - | - | ✔ | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | - | - | - | ✔ |
pinCodeCapability |
✔ | ✔ | ✔ | ✔ | - | - | ✔ | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | - | ✔ | ✔ | ✔ |
pinCode |
- | - | - | ✔ | - | - | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | - | ✔ | ✔ | ✔ |
autoConnectCapability |
✔ | ✔ | ✔ | ✔ | - | - | ✔ | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | - | ✔ | ✔ | ✔ |
autoConnect |
✔ | ✔ | ✔ | ✔ | - | - | ✔ | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | - | - | - | ✔ |
securityTypeCapability |
✔ | ✔ | ✔ | ✔ | - | - | ✔ | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | - | ✔ | ✔ | ✔ |
security |
- | - | - | ✔[2] | - | - | - | - | - | - | - | - | - | ✔[2] | ✔[2] | ✔[2] | ✔[2] | ✔[3] | ✔[3] | ✔[3] | ✔[3] | ✔[3] | ✔[3] | ✔[3] | ✔[3] | ✔[3] | ✔[3] | - | ✔[3] | ✔[3] | ✔[2] |
portName |
✔ | ✔ | ✔ | ✔ | - | - | ✔ | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | - | ✔ | ✔ | ✔ |
portSettings |
✔ | ✔ | ✔ | ✔ | - | - | ✔ | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | - | ✔ | ✔ | ✔ |
timeoutMillis |
✔ | ✔ | ✔ | ✔ | - | - | ✔ | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | - | ✔ | ✔ | ✔ |
deviceType |
✔ | ✔ | ✔ | ✔ | - | - | ✔ | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | - | ✔ | ✔ | ✔ |
opened |
✔ | ✔ | ✔ | ✔ | - | - | ✔ | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | - | ✔ | ✔ | ✔ |
[1] | ファームウェアバージョン3.0以降が必要です |
[2] | 設定・取得できるSecurityTypeはPINコードもしくはSSP |
[3] | 設定・取得できるSecurityTypeはPINコードもしくはDisable |
3.4.1. Bluetooth設定変更フロー¶
StarBluetoothManagerクラスを利用し、以下の手順に沿ってプリンタのBluetooth設定を変更します。

// get SMBluetoothManager
SMBluetoothManager *bluetoothManager = [SMBluetoothManagerFactory getManager:portName
emulation:emulation];
// Open port
if ([bluetoothManager open] == NO) {
// Fail to open port.
return;
}
// Load Bluetooth settings
if ([bluetoothManager loadSetting] == NO) {
// Fail to load settings.
[bluetoothManager close];
return;
}
// Set Bluetooth settings
// Example: set "Star Micronics" to the deviceName.
bluetoothManager.deviceName = @"Star Micronics";
// Apply Bluetooth settings
if ([bluetoothManager apply] == NO) {
// Fail to apply settings.
[bluetoothManager close];
return;
}
// Close port
[bluetoothManager close];
BluetoothSettingViewController.m を参照ください。
3.4.2. SMDeviceType¶
プリンタタイプを示す定数です。
宣言
typedef enum _SMDeviceType { SMDeviceTypeDesktopPrinter, SMDeviceTypePortablePrinter, } SMDeviceType;
定数
名称 説明 SMDeviceTypeDesktopPrinter デスクトッププリンタ SMDeviceTypePortablePrinter モバイルプリンタ
各モデルに対して適用すべき定数は以下のとおりです。
モデル |
エミュレーション |
定数 |
---|---|---|
mC-Print2 | StarPRNT | SMDeviceTypePortablePrinter |
mC-Print3 | StarPRNT | SMDeviceTypePortablePrinter |
mPOP | StarPRNT | SMDeviceTypePortablePrinter |
FVP10 | StarLine | SMDeviceTypeDesktopPrinter |
TSP100IIIBI | StarGraphic | SMDeviceTypeDesktopPrinter |
TSP650II | StarLine | SMDeviceTypeDesktopPrinter |
TSP650IISK | StarLine | SMDeviceTypeDesktopPrinter |
TSP700II | StarLine | SMDeviceTypeDesktopPrinter |
TSP800II | StarLine | SMDeviceTypeDesktopPrinter |
SM-S210i | StarPRNT | SMDeviceTypePortablePrinter |
EscPosMobile | ||
SM-S220i | StarPRNT | SMDeviceTypePortablePrinter |
EscPosMobile | ||
SM-S230i | StarPRNT | SMDeviceTypePortablePrinter |
EscPosMobile | ||
SM-T300i/T300 | StarPRNT | SMDeviceTypePortablePrinter |
EscPosMobile | ||
SM-T400i | StarPRNT | SMDeviceTypePortablePrinter |
EscPosMobile | ||
SM-L200 | StarPRNT | SMDeviceTypePortablePrinter |
SM-L300 | StarPRNT | SMDeviceTypePortablePrinter |
SP700 | StarDotImpact | SMDeviceTypeDesktopPrinter |
3.4.3. SMBluetoothSecurity¶
Bluetoothセキュリティタイプを示す定数です。
宣言
typedef enum _SMBluetoothSecurity { SMBluetoothSecurityDisable, SMBluetoothSecuritySSP, SMBluetoothSecurityPINcode } SMBluetoothSecurity;
定数
名称 説明 SMBluetoothSecurityPINcode PINコード入力によるセキュリティ SMBluetoothSecuritySSP インターフェイスカードのボタン押下によるセキュリティ SMBluetoothSecurityDisable セキュリティなし
3.4.4. SMBluetoothSettingCapability¶
Bluetooth設定可否を示す定数です。
宣言
typedef enum _SMBluetoothSettingCapability { SMBluetoothSettingCapabilitySupport, SMBluetoothSettingCapabilityNoSupport } SMBluetoothSettingCapability;
定数
名称 説明 SMBluetoothSettingCapabilitySupport 現在接続中のプリンタではその項目・機能が設定できることを示します。 SMBluetoothSettingCapabilityNoSupport 現在接続中のプリンタではその項目・機能が設定できないことを示します。
3.4.5. portName¶
コンストラクタで指定したportNameを取得します。
宣言
@property (nonatomic, readonly) NSString *portName;
3.4.8. deviceName¶
Bluetoothデバイス名を示します。
設定するためには、本プロパティを変更後に apply メソッドを実行します。
使用可能文字
0-9 a-z A-Z ; : ! ? # $ % & , . @ _ - = Space / * + ~ ^ [ { ( ] } ) | \
文字数制限
1文字以上 かつ 16文字以下
注意事項
Bluetooth Low Energyインターフェイスの場合、変更したBluetoothデバイス名は、デバイスの電源再投入・再接続を行った後に有効になります。
宣言
@property(nonatomic, retain) NSString *deviceName;
3.4.9. iOSPortName¶
iOSポート名を示します。
設定するには、本プロパティを変更後 apply メソッドを実行します。
使用可能文字
0-9 a-z A-Z ; : ! ? # $ % & , . @ _ - = Space / * + ~ ^ [ { ( ] } ) | \
文字数制限
1文字以上 かつ 16文字以下
宣言
@property(nonatomic, retain) NSString *iOSPortName;
3.4.10. autoConnect¶
AutoConnection(自動接続機能)のオン/オフを示します。
設定するには、本プロパティを変更後 apply メソッドを実行します。
宣言
@property(nonatomic, assign) BOOL autoConnect;
3.4.11. security¶
Bluetoothセキュリティタイプを示します。
設定するには、本プロパティを変更後 apply メソッドを実行します。
宣言
@property(nonatomic, assign) SMBluetoothSecurity security;
3.4.12. pinCode¶
Bluetoothペアリング時に使用するPINコードを示します。
現在の設定値を取得することはできません。
設定するには、本プロパティを変更後 apply メソッドを実行します。
使用可能文字
0-9
(SM-L200、SM-L300)0-9 a-z A-Z
(その他のモデル)
文字数制限
- 4文字 (SM-L200、SM-L300)
- 4文字以上 かつ 16文字以下(その他のモデル)
宣言
@property(nonatomic, retain) NSString *pinCode;
3.4.13. deviceNameCapability¶
Bluetoothデバイス名の設定可否情報を示します。
宣言
@property (assign, readonly) SMBluetoothSettingCapability deviceNameCapability;
3.4.14. iOSPortNameCapability¶
iOSポート名の設定可否情報を示します。
宣言
@property (assign, readonly) SMBluetoothSettingCapability iOSPortNameCapability;
3.4.15. autoConnectCapability¶
AutoConnectionの設定可否情報を示します。
宣言
@property (assign, readonly) SMBluetoothSettingCapability autoConnectCapability;
3.4.16. securityTypeCapability¶
Bluetoothセキュリティタイプの設定可否情報を示します。
宣言
@property (assign, readonly) SMBluetoothSettingCapability securityTypeCapability;
3.4.17. pinCodeCapability¶
PINコード設定可否情報を示します。
宣言
@property (assign, readonly) SMBluetoothSettingCapability pinCodeCapability;
3.4.18. initWithName¶
インスタンスを生成します。
宣言
-(id) initWithPortName:(NSString *)portName deviceType:(SMDeviceType)deviceType;
引数
引数 説明 型 portName getPort メソッドのportNameと同じです。 NSString * deviceType プリンタータイプ定数 SMDeviceType 戻り値
説明 型 SMBluetoothManager オブジェクト失敗時は、nil が返されます。SMBluetoothManager
Bluetooth設定変更の手順は、 Bluetooth設定変更フロー を参照ください。
注釈
StarIO_Extension.xcframework に含まれる SMBluetoothManagerFactory では、プリンタのエミュレーションに対して適切な SMBluetoothManager オブジェクトを取得することができます。
3.4.19. open¶
プリンターと通信するためのポートをオープンします。
重要
本メソッド実行後は、必ず loadSetting メソッドを実行し現在の設定を取得してください。
宣言
- (BOOL) open;
引数
なし
戻り値
説明 型 成功・失敗 BOOL
Bluetooth設定変更の手順は、 Bluetooth設定変更フロー を参照ください。
3.4.20. loadSetting¶
接続したプリンターから設定を取得します。
宣言
- (BOOL) loadSetting;
引数
なし
戻り値
説明 型 成功・失敗 BOOL
Bluetooth設定変更の手順は、 Bluetooth設定変更フロー を参照ください。
3.4.21. close¶
プリンターと通信するためのポートをクローズします。
宣言
- (void) close;
引数
なし
戻り値
なし
Bluetooth設定変更の手順は、 Bluetooth設定変更フロー を参照ください。
3.4.22. apply¶
以下メンバーで指定した値をプリンターに設定します。
宣言
- (BOOL) apply;
引数
なし
戻り値
説明 型 成功・失敗 BOOL
Bluetooth設定変更の手順は、 Bluetooth設定変更フロー を参照ください。