Skip to content

Improve speed of printing via bluetooth? #136

Open
@marcgug

Description

@marcgug

Description

Long delay when printing via bluetooth: 4-5 seconds

Your device where the bug occurs

  • Device: iPad Gen 9
  • OS: iOS 18.3.1
  • Version: 2.8.0

Your printer

  • Model Names: TSP100III
  • Firmware Version: 3.0
  • Interface: Bluetooth

Your development environment

Mac OS 15.3.2

Additional context

Is there any way to speed up printing via bluetooth? I have added timing logs and it takes 4-5 seconds from the time of making the StarPrinter(.bluetooth, address) command to actually completing the printer.print() command. Here is an excerpt what my code looks like:

  guard let address: String = Defaults.object(for: .starMicronicsPrinterAddress) else { return showAlert() }
    
    let startTime = measureStart()
    Log.verbose("Starting StarMicronics printer operation", context: "StarMicronics")

    let cb = StarXpandCommand.StarXpandCommandBuilder()
    let db = StarXpandCommand.DocumentBuilder()

    _ = cb.addDocument(cmd(db))

    let command = cb.getCommands()

    let printer = StarPrinter(.bluetooth, address)

    Task {
      do {
        Log.verbose("Attempting to open printer connection", context: "StarMicronics")
        let openStartTime = measureStart()
        try await printer.open()
        measure(openStartTime, "Printer open")
        defer { Task { await printer.close() } }
        
        Log.verbose("Sending print command", context: "StarMicronics")
        let printStartTime = measureStart()
        try await printer.print(command: command)
        measure(printStartTime, "Print command execution")
        
        measure(startTime, "Total StarMicronics operation")
        Log.verbose("Success", context: "StarMicronics")
      } catch let error {
        measure(startTime, "Total StarMicronics operation (failed)")
        Log.error(error, context: "StarMicronics")
      }

Any suggestions on how to speed up printing would be greatly appreciated. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions