star-micronics / StarPRNT-SDK-iOS-Swift

StarPRNT SDK for iOS including libraries for supporting application development for Star printers.
https://www.star-m.jp/products/s_print/sdk/starprnt_sdk/manual/ios_swift/en/index.html
Other
41 stars 7 forks source link

Search returns an empty array #3

Closed arturdev closed 3 years ago

arturdev commented 3 years ago
SMPort.searchPrinter(target: "ALL:") as? [PortInfo]

This returns an empty array, though the sample app works. What can be the issue?

gare-bear commented 3 years ago

@arturdev what connection type does your printer have?

arturdev commented 3 years ago

it is a bluetooth printer

arturdev commented 3 years ago

@gare-bear The log from this demo app

PrinterSetting { portName: BT:TSP100 portSettings: macAddress: 00:11:62:18:35:61 modelName: TSP143IIIBI GY emulation: 3 cashDrawerOpenActiveHigh: true allReceiptsSettings: 7 selectedPaperSize: threeInch selectedModelIndex: tsp100 }

gare-bear commented 3 years ago

@arturdev there are two key/value pairs you should add to your plist to ensure you have the proper permission to discover Bluetooth printers.

This is mentioned in section 2 of our documentation

Check if these are missing from your plist

arturdev commented 3 years ago

The second one is added, but the first one is missing. Let me add it and try again

gare-bear commented 3 years ago

@arturdev any luck?

arturdev commented 3 years ago

The person who owns the printer is in a different timezone, I'm waiting for him. Will report back as soon as he tests it.

Thanks for your interest, appreciate that ❤️

arturdev commented 3 years ago

After adding the missing entry to the info.plist, now it is able to find the printer. The printing returns success status code but nothing is printed in reality. Trying to figure out what is the issue. Thanks

arturdev commented 3 years ago

It seems correct. I'm using the same function for printing as in the demo app. https://github.com/star-micronics/StarPRNT-SDK-iOS-Swift/blob/master/SDK/Swift%20SDK/Communications/Communication.swift#L28

And the completionHandler is being called with SMStarIOResultCodeSuccess but nothing is printed.

gare-bear commented 3 years ago

@arturdev You're probably trying to print text which the TSP143III doesn't support. This particular printer is Raster only, so you must send your data in graphical form using a UIImage. Then use the ISCBBuilder and the appendBitmap method to print the image. Here you can find the supported methods for each printer model.

arturdev commented 3 years ago

Yes, I was trying to print a text. So I need to programmatically check what type the currently connected printer supports (text/image/etc..) and build the print-data accordingly, right?

gare-bear commented 3 years ago

Exactly! You can use the ModelCapability class to determine what emulation the printer supports. Just FYI the correct emulation is starGraphic.

arturdev commented 3 years ago

@gare-bear Hi again. I'm having some issue when I'm printing second time in a row. First time it prints successfully. But second time it doesnt.

My flow is the following:

When user prints, I'm creating StarIoExtManager instance with the selected printer port settings. Then, sending commands (I'm using the same Communications class which is in this demo project). The second time I'm getting errorOpenPort. Is there anything wrong I'm doing?

arturdev commented 3 years ago

@gare-bear Can you help, please?

gare-bear commented 3 years ago

@arturdev please post this as a new issue and i'll be happy to help you. please post your code as well.