I'm trying to control the thermal printer with a Bluetooth connection using Swift5, CoreBluetooth.
The Bluetooth connection (pairing) with the printer was successful, but I don't know how to print data to the printer.
Is it impossible without the manufacturer's driver and library?
Or is it possible with CoreBluetooth or other generic libraries?
I don't really understand how to connect to external hardware such as printers, so I would appreciate it if you could give me some helpful information on how to look into and think about it.
●●● Resolved Method ●●●
Thank you to everyone who responded.
After the question, I got a quick fix from the library source code I found in my research, so I'll leave some information for your reference.
I was able to use this library as a reference to output it.
In terms of content, it seems to be implemented only with CoreBluetooth.
https://github.com/KevinGong2013/Printer
What I needed was...
(1) I was unable to select the appropriate Service UUID or Characteristic UUID among the UUID information for the printer obtained from the scan. (I think this basically requires information from the printer manufacturer, but I tried it while switching the UUID.)
(2) For output of data, writeValue(_:for:type:) of CoreBluetooth is used.
I tried this too, but I didn't know because there was no response due to (1).
Other areas that might be better to use the library are all the processing as shown in the source code group below.
I don't understand the contents properly, but it seems that the output cannot be done without this kind of processing.
It may be similar to the process of creating a video file from an image file.
https://github.com/KevinGong2013/Printer/tree/master/Printer/Source/Ticket
In any case, it seems easy to print (2) to the printer by incorporating this library.
swift bluetooth
Is it impossible without the manufacturer's drivers and libraries?
I'm not saying it's impossible, but basically you'll have to refer to the specifications provided by various printer manufacturers.
Manufacturers may provide libraries for printing via Bluetooth, such as Star webPRNT SDK, or they may be self-made from printer specifications.
As far as I know, there are no common specifications that can be used for many types of printers, so I don't expect much of an OSS library that can be used conveniently regardless of printer...(This is just from my experience, so I'm sorry if you have any.)
Please give me some helpful information on how to look into it and think about it.
Therefore, in order to find out about Bluetooth printing, you should first refer to the information from the manufacturer of your printer.
Insert first according to the results:
The libraries around them are fine with commonly used features such as printable characters, line breaks, and alignment, but they may not be able to switch code pages, switch/expand fonts, or print images/barcodes.
Many of the control code/command systems used are ESC/P, ESC/POS derived from EPSON, but some vendors have expanded themselves and are often not compatible with details.
Also, international vendors (such as Zebra) use their own control code/command system.
If you want to control the decorations and layout of any characters, you will need to read the vendor's command reference carefully.
The vendor of the printer you are trying to use will probably have SDKs.
Some of the famous things are as follows, but they may come from a single vendor.
Receipt printer|Introduce development assistance tools
StarwebPRNT browser
SDK download
Downloading and Supporting Link OS Multiplatform SDK
Other than these, they may be prepared.
Contact your printer vendor.
There is also a common cross-trade specification.(I'm not sure if it's mobile.)
What is ReceiptLine
There are other libraries published on npm and GitHub, so you can look for them according to your preference.
In any case, I don't think there is a solution that can be used regardless of vendor or model.
If you list the vendor and model of the printer you are using in your question, you are more likely to get specific advice and answers.
However, I rarely see such Q&A articles in Japanese, so I may not be able to expect much.
Print on iPad
The English version of StackOverflow has a few questions.
BrotherLabelprinter.Bluetooth vs AirPrint [closed]
iOS send file to printer using bluetooth
Change font size programmatically on thermal Bluetooth Printer
How to connect Thermal Bluetooth Printer to iOS devices
© 2024 OneMinuteCode. All rights reserved.