啓枢アーカイブ
製品ドキュメント、インターフェース資料、エンジニアリング記録の入口です。
Java SDK
Java、Android、ネットワーク印刷、Bluetooth 印刷向けの NIB SDK 導入説明。
Java SDK は Android アプリ、JVM ツール、ネットワークプリンター、クラシック Bluetooth 接続に適しています。導入時はまず実際の接続を Device にラップし、その後でテンプレートに Script を構築させるか、書き込みパイプラインから直接バイト列を送ります。
Maven モジュール
Section titled “Maven モジュール”Maven group は com.boxliy.nib です。
| モジュール | 用途 |
|---|---|
nib |
標準集約版。プロダクト統合に適しています。 |
nib-core |
Device、Script、WritePipeline、受信ソース、クエリ分配。 |
nib-esc-boxliy、nib-tspl-boxliy、nib-cpcl-boxliy |
Boxliy 方言ビルダーとレスポンス parser。 |
nib-esc、nib-tspl、nib-cpcl |
Aryten 互換方言。 |
nib-esc-lin8inch、nib-tspl-lin8inch |
Lin8inch 方言。 |
nib-network |
TCP/IP ネットワークプリンター接続。 |
nib-bluetooth |
Java クラシック Bluetooth 抽象。 |
| Android classic アダプター | リポジトリには Android クラシック Bluetooth アダプターのソースがあります。独立した配布モジュールかどうかは、実際の配布バージョンに従ってください。 |
ソース内では Java BLE モジュールを確認できていません。Android BLE を導入する必要がある場合は、配布バージョンまたはプロジェクトのアダプター層に従って確認し、クラシック Bluetooth モジュールから推測しないでください。
Core オブジェクト
Section titled “Core オブジェクト”Device は最小デバイス契約です。
public interface Device { String name(); boolean connected(); void write(byte[] data) throws IOException; byte[] read(int timeoutMs) throws IOException; void close() throws IOException;}Script は構築済みバイト列を保持し、binary()、hex()、base64()、string()、length() を提供します。WritePipeline は分割書き込みを担当し、WriteOptions は ChunkPolicy、WriteMode、キャンセル、タイムアウト、backpressure を設定し、WriteResult を返します。
デフォルト分割サイズは NibDefaults.CHUNK_SIZE から来ており、現在は 1024 バイトです。
Java の EscBoxliy には text() メソッドがありません。通常のテキストには raw(...) を使ってください。
import com.boxliy.nib.core.Device;import com.boxliy.nib.esc.EscBoxliy;
Device device = Device.none();
EscBoxliy.of(device) .reset() .raw("NIB SDK\r\n") .feed(2) .write();Device.none() はテスト用のスクリプト生成に適しており、実プリンターへは接続しません。実プロジェクトでは、ネットワーク、クラシック Bluetooth、または Android classic 接続から得られた Device を渡します。
先にスクリプトを構築してから書き込む場合は次のようにします。
import com.boxliy.nib.core.WriteOptions;import com.boxliy.nib.core.WritePipeline;import com.boxliy.nib.core.WriteResult;import com.boxliy.nib.tspl.TsplAryten;
byte[] data = TsplAryten.of() .size(40, 30) .cls() .text(20, 20, "NIB SDK") .print(1) .build() .binary();
WriteResult result = WritePipeline.write( device, data, WriteOptions.defaults(), null);ネットワーク印刷
Section titled “ネットワーク印刷”nib-network は Network.connect(...) を提供します。
import com.boxliy.nib.core.Device;import com.boxliy.nib.network.Network;
Device device = Network.connect("192.168.1.50", 9100);デフォルト接続タイムアウトは 10000 ms です。Network.connect(host, port, timeoutMs) も呼び出せます。ネットワーク印刷前に、host、port、タイムアウト、リトライ、ログ戦略を確認してください。ログには endpoint とバイト長を記録できますが、機密性のある印刷内容は記録しないでください。
Android とクラシック Bluetooth
Section titled “Android とクラシック Bluetooth”Java リポジトリでは nib-bluetooth と Android classic アダプターのソースが確認されています。Android classic 導入では通常、次が必要です。
- Android バージョンに応じて Bluetooth 権限をリクエストします。
- スキャンするか、ペアリング済みデバイスを選択します。
- クラシック Bluetooth socket を確立します。
Deviceにラップします。- 方言ビルダーで
Scriptを生成します。 - ビルダーの
write()またはWritePipeline.write(...)で送信します。 - ページ破棄またはセッション終了時に接続を閉じます。
権限、ライフサイクル、再接続ロジックを印刷テンプレートに書き込まないでください。
受信、クエリ、解析
Section titled “受信、クエリ、解析”core は ReceiveSource、PollingReceiveSource、CallbackReceiveSource、ReceiveListener、QueryDispatcher、PendingQuery、ResponseMatcher を提供します。
Boxliy 方言 parser 名は次のとおりです。
| 方言 | parser |
|---|---|
| ESC | EscResponseParser |
| TSPL | TsplResponseParser |
| CPCL | CpclResponseParser |
ステータス、電池残量、型番、シリアル番号などのクエリは、すべてセッション層で一元的に処理し、デバイスファームウェアに合わせて妥当なタイムアウトを設定してください。
Methods and Commands
The tables below list the public entry points integration teams usually need. Builder methods generate printer commands; actual availability still depends on the ESC, TSPL, CPCL, or Lin8inch command family supported by the target firmware.
Core, Connection, and Writing
| Object | Method / Command | Purpose | Parameters |
|---|---|---|---|
Device / Script | name(), connected(), write(data), read(timeoutMs), close(), binary(), hex(), base64(), string(), length() | Abstracts the real printer connection for templates, write pipelines, and query handling. | `timeoutMs` is the read timeout; `Script` is used to inspect or store built bytes. |
WritePipeline / WriteOptions | write(device, data, options, listener), withChunkPolicy(), withMode(), withCancellationToken(), withTimeout(), withBackpressure() | Writes built bytes to a device with chunking, timeout, cancellation, and flow-control rules. | `ChunkPolicy.fixed(size)` controls chunking; listener receives `WriteProgress`; returns `WriteResult`. |
PrinterDiscovery / PrinterConnector | scan(), stop(), connect(printer, options), disconnect(), state() | Scans, connects, and disconnects printers so platform connections can be unified under NIB core. | `ConnectionOptions` contains transport, timeoutMs, and autoReconnect. |
ReceiveSource / QueryDispatcher | start(listener), stop(), accept(data), receive(data), query(matcher, timeoutMs), cancel(), shutdown() | Routes device responses into listeners or query dispatchers for status, battery, model, and similar queries. | `ResponseMatcher` returns a matched result; `PendingQuery` can `get()` with or without timeout. |
Command Builders
| Object | Method / Command | Purpose | Parameters |
|---|---|---|---|
EscBoxliy / EscAryten | of(), newLine(), location(), image(), line(), cut(), feed(), lineRow(), lineDot(), backLineDot(), enable(), wakeup(), position(), stopJob(), setBTType(), lineDotCut(), thickness(), learnLabelGap(), paperType(), batteryVolume(), info(), model(), version(), printerVersion(), sn(), state(), status(), name(), mac(), reset(), raw(), imageGray(), build(), write(), clear() | Builds ESC/Boxliy commands for receipt, portable, and ESC-compatible printers. | `of` accepts device/charset; `raw` accepts a template and args; `write(chunkSize, progress)` writes directly. |
TsplBoxliy / TsplAryten | of(), size(), gap(), bline(), continuous(), label(), direction(), codePage(), speed(), density(), reference(), offset(), shift(), gapSensor(), ribbon(), cut(), tear(), peel(), detect(), readState(), status(), state(), realtimeStatus(), sn(), sns(), version(), versions(), model(), models(), batteryVolume(), cls(), text(), barcode(), qrcode(), dmatrix(), line(), box(), circle(), ellipse(), image(), print(), raw(), build(), write(), clear() | Builds TSPL label commands for templates with paper size, coordinates, barcodes, and QR codes. | Coordinates and sizes are ints; enums include Direction, Mirror, CodePage, Font, Rotation, BarcodeType, and QrLevel. |
CpclBoxliy / CpclAryten | of(), begin(), pageWidth(), feed(), gapSense(), barSense(), paperType(), text(), barcode(), qrcode(), line(), box(), bold(), underline(), waterMark(), inverseLine(), image(), form(), print(), status(), realtimeStatus(), sn(), model(), version(), batteryVolume(), raw(), build(), write(), clear() | Builds CPCL label commands for page setup, text, lines, barcodes, and images. | Page, text, barcode, QR, line, box, and image parameters follow CPCL commands; `PaperType` controls gap/bar sensing. |
EscLin8inch | of(), batteryLevel(), extendedModel(), bootVersion(), advancedDensity(), advancedDensityStatus(), grayMode(), mediaProfile(), mediaProfileStatus(), wirelessProvisioning(), wirelessProvisioningStatus(), compressedRasterTransport(), mediaTag(), mediaTagUid(), consumedMediaLength(), remainingMediaLength(), restoreLabelStartPosition(), alternateMotionProfile() | Adds Lin8inch telemetry, media, provisioning, and raster transport commands on top of ESC. | Lin8inch extensions are mainly for queries, media configuration, and WiFi provisioning; do not call them on unsupported models. |
TsplLin8inch | of(), automaticStatusFeedback(), printCompletion(), printerStatus(), firmwareVersion(), serialNumber(), macAddress(), deviceSpeed(), deviceSelfTest(), thermalStatus(), productId(), versionInfo(), selfTestPage(), modelSetting(), serialSetting(), versionSetting(), gbkCodepage(), utf8Codepage(), gapDetection(), configureStock(), configurePresentation(), twoColorRibbon(), directThermal() | Adds Lin8inch status feedback, media, ribbon, and presentation commands on top of TSPL. | Accepts booleans, speed, status flags, stock sensors, presentation mode, mark/gap, and offset. |
Response Parsing
| Object | Method / Command | Purpose | Parameters |
|---|---|---|---|
EscResponseParser / TsplResponseParser / CpclResponseParser | parse(raw), parse(query, raw) | Parses printer responses into status, battery, text, MAC, event, or unknown response objects. | `raw` is byte[]; response objects expose type, rawHex, statusFlags, isReady, batteryLevel, text, macAddress, and description. |
実践上のおすすめ
Section titled “実践上のおすすめ”- まず機種が対応する方言を確認してから、
EscBoxliy、TsplBoxliy、CpclBoxliy、または Aryten/Lin8inch ビルダーを選びます。 - Android classic と JVM classic では接続方式が異なります。テンプレート層がプラットフォームクラスに依存しないようにしてください。
- 大きな画像と連続印刷では、実デバイスで分割サイズを検証する必要があります。
- 難読化時は、配布パッケージが保持を要求する公開 SDK API を残してください。