star-micronics / StarXpand-SDK-iOS

StarXpand SDK for iOS is a software development kit for supporting application development for Star Micronics devices.
https://star-m.jp/starxpandsdk-oml.html
Other
27 stars 5 forks source link

is there a way to reconnect the printer using identifier, mac address,...? #16

Closed hoanhtdd closed 1 year ago

hoanhtdd commented 1 year ago

is there a way to reconnect the printer using identifier, mac,...? i see sdk is scanning only connected devices , So how are the devices that are not connected to be scanned?

eliottha commented 1 year ago

How do you mean "reconnect"?

If you want to print to a Star printer and have the identifier and connection method, you can do the following:

let identifier = "" // fill in identifier
let interfaceType: StarIO10.InterfaceType = .lan | .usb | .bluetooth | .bluetoothLE

let starConnectionSettings = StarConnectionSettings(interfaceType: interfaceType, identifier: identifier)
let starPrinter = StarPrinter(starConnectionSettings)

and print with

try await starPrinter.print(command: command)

I use this to create a Printer object and save that in UserDefaults and it works perfectly.

gare-bear commented 1 year ago

@hoanhtdd The printer must be connected prior to use, by whichever means of communication you plan to use.

USB: connect the cable BT: Pair the printer to the device (Settings --> Bluetooth) LAN: connect the pritner to the network, get an IP, tablet must be on the same network to discover

The only exception is BLE, the app will discover it and there is no formal "pairing process"