B4i Library iSD BLE Printer

I am happy to present my library to print with Iphone (and iPad) with Bluetooh (BLE). Now I can print the images. If you want to have the activation code (Freeing all the functions) contact me in private.
(For B4J versione see Here, for B4A versione see Here, for ZEBRA printer Here)

This version requires an activation code. If you don't have a code, it will work in DEMO mode and you can print for just one minute every 4 minutes.


iSD_BLE_Printer

Author:
Star-Dust
Version: 0.25
  • BLE_Printer
    • Events:
      • Connected (services As List)
      • Disconnected
      • ImagePrintingCompleted
      • PrinterFound (Name As String, ID As String)
      • WriteComplete (Characteristic As String, Success As Boolean)
    • Fields:
      • CharatteristicName As NSString*
      • ServiceName As NSString*
    • Functions:
      • AddTab (ArrayTab As Int()) As NSString*
        Add Tab
        eg. PrinterBLE.AddTab(Array As Byte(100,150,121))
      • CenterJustify As NSString*
        after this command calls SendBufferToPrinter
      • Class_Globals As NSString*
      • Connect (ID As NSString*) As NSString*
      • Initialize (ba As B4I*, CallBack As NSObject*, EventName As NSString*, EncodingType As NSString*, CodeActivation As NSString*) As NSString*
        Initializes the object. You can add parameters to this method if needed.
      • InitializePrinter As NSString*
      • IsInitialized As BOOL
        Verifica se l'oggetto sia stato inizializzato.
      • LeftJustify As NSString*
        after this command calls SendBufferToPrinter
      • PrintBitmap (bmp As B4IBitmap*)
      • RightJustify As NSString*
        after this command calls SendBufferToPrinter
      • ScanPrinter As NSString*
      • SetCodePage (Code As Unsigned char) As NSString*
        es. Printer.SetCodePage(06) for umlauts char
      • Write (Text As NSString*) As NSString*
        Write (Print) a Text
      • Write_ArrayByte (B As Unsigned char()) As NSString*
        Write (Send to Printer) a Array of Byte
        eg. PrinterBLE.Write_ArrayByte(Array As Byte(0x1D,150,23))
        eg. PrinterBLE.Write_ArrayByte("Text".GetBytes("UTF8"))
      • WriteBarCode (Code As NSString*) As NSString*
      • WriteLine (Text As NSString*) As NSString*
        Write (Print) a Text + CHLF
      • WriteList (list As B4IList*) As NSString*
        Write (Print) a List
    • Properties:
      • CodeTable
        es. printer.setCodeTable(Ecoding.Code_WPC1252)
        aftet this command calls SendBufferToPrinter
      • isConnect As BOOL [read only]
      • Spacing
        after setSpacing command calls SendBufferToPrinter
  • ESC_POS
    • Fields:
      • BoldOff As NSString*
      • BoldOn As NSString*
      • DoubleOff As NSString*
      • DoubleOn As NSString*
      • FontA_Bold As NSString*
      • FontA_DoubleHight As NSString*
      • FontA_DoubleWide As NSString*
      • FontA_DoubleWideHeight As NSString*
      • FontA_Normal As NSString*
      • FontB_Bold As NSString*
      • FontB_DoubleHeight As NSString*
      • FontB_DoubleWide As NSString*
      • FontB_DoubleWideHeight As NSString*
      • FontB_Normal As NSString*
      • Horizzontal As NSString*
      • InitializePrinter As NSString*
      • NoUnderline As NSString*
      • QueryErrorCauses As NSString*
      • QueryOfflineCauses As NSString*
      • QueryPaperStatus As NSString*
      • QueryPrinterStatus As NSString*
      • Underline1 As NSString*
      • Underline2 As NSString*
      • Vertical As NSString*
    • Functions:
      • Process_Globals As NSString*
        Code module
        Subs in this code module will be accessible from all modules.
  • Encoding
    • Fields:
      • Chinese As NSString*
      • ChineseS As NSString*
      • Code_PC437 As Int
      • Code_PC850 As Int
      • Code_PC857 As Int
      • Code_PC858 As Int
      • Code_PC860 As Int
      • Code_PC863 As Int
      • Code_WPC1252 As Int
      • DOS_Latin_1 As NSString*
      • IBM_PC As NSString*
      • ISO8859 As NSString*
      • UTF8 As NSString*
      • Windows1252 As NSString*
    • Functions:
      • Process_Globals As NSString*
        Code module
        Subs in this code module will be accessible from all modules.
 

Attachments

  • iSD_BLE_Printer 0.25.zip
    256.9 KB · Views: 26
  • SampleBLE_Printer.zip
    111.6 KB · Views: 19
Last edited:

Ali Alsaedi

Member
Licensed User
Longtime User
Yes, I copied the files on the Mac server ... I have no problem compiling ... the program gives an error when running ... the program is installed on the simulator but gives an error and the program closes ... If the files are not copied at all, the program Cannot be installed ...
Did the library files change in the new changes?
 

Star-Dust

Expert
Licensed User
Longtime User
Yes, I copied the files on the Mac server ... I have no problem compiling ... the program gives an error when running ... the program is installed on the simulator but gives an error and the program closes ... If the files are not copied at all, the program Cannot be installed ...
Did the library files change in the new changes?
No I'm sorry there is no change.
But the thing I want to point out to you is that line 12 is not an instruction. It is considered by the compiler only if you are compiling as a library, but in release or debug it is ignored. An error in that row is strange.

Try the updated example and open it if it signals you an error and in what line
 

Ali Alsaedi

Member
Licensed User
Longtime User
B4X:
Error occurred on line: 12 (Main)
Unknown command: 0
Stack Trace: (
  CoreFoundation       __exceptionPreprocess + 331
  libobjc.A.dylib      objc_exception_throw + 48
  CoreFoundation       +[NSException raise:format:] + 197
  BLE Printer          -[B4IShell raiseEventImpl:method:args::] + 2258
  BLE Printer          -[B4IShellBI raiseEvent:event:params:] + 1673
  BLE Printer          -[B4IStaticModule initializeModule] + 434
  BLE Printer          -[b4i_main initializeStaticModules] + 67
  BLE Printer          -[B4IShellBI raiseEvent:event:params:] + 236
  BLE Printer          __33-[B4I raiseUIEvent:event:params:]_block_invoke + 50
  libdispatch.dylib    _dispatch_call_block_and_release + 12
 libdispatch.dylib    _dispatch_client_callout + 8
 libdispatch.dylib    _dispatch_main_queue_callback_4CF + 1276
 CoreFoundation       __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
 CoreFoundation       __CFRunLoopRun + 2310
 CoreFoundation       CFRunLoopRunSpecific + 626
 GraphicsServices     GSEventRunModal + 65
 UIKitCore            UIApplicationMain + 140
 BLE Printer          main + 112
 libdyld.dylib        start + 1
 ???                  0x0 + 1
)
 

Star-Dust

Expert
Licensed User
Longtime User
B4X:
Error occurred on line: 12 (Main)
Unknown command: 0
Stack Trace: (
  CoreFoundation       __exceptionPreprocess + 331
  libobjc.A.dylib      objc_exception_throw + 48
  CoreFoundation       +[NSException raise:format:] + 197
  BLE Printer          -[B4IShell raiseEventImpl:method:args::] + 2258
  BLE Printer          -[B4IShellBI raiseEvent:event:params:] + 1673
  BLE Printer          -[B4IStaticModule initializeModule] + 434
  BLE Printer          -[b4i_main initializeStaticModules] + 67
  BLE Printer          -[B4IShellBI raiseEvent:event:params:] + 236
  BLE Printer          __33-[B4I raiseUIEvent:event:params:]_block_invoke + 50
  libdispatch.dylib    _dispatch_call_block_and_release + 12
libdispatch.dylib    _dispatch_client_callout + 8
libdispatch.dylib    _dispatch_main_queue_callback_4CF + 1276
CoreFoundation       __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
CoreFoundation       __CFRunLoopRun + 2310
CoreFoundation       CFRunLoopRunSpecific + 626
GraphicsServices     GSEventRunModal + 65
UIKitCore            UIApplicationMain + 140
BLE Printer          main + 112
libdyld.dylib        start + 1
???                  0x0 + 1
)
See this thread:

And this:

Could you have version 5.5 on the server? It doesn't seem like a library problem
 
Last edited:

Ali Alsaedi

Member
Licensed User
Longtime User
Thank you .. it was correct ...
But now I can not print photos and barcodes ...
And there is a problem with how to connect to the printer, and any device with Bluetooth on is connected, and every time we have to click on the scanner button of the printer ... Is it possible that it displays the list of devices and we click on the printer in question?
 

Star-Dust

Expert
Licensed User
Longtime User
Thank you .. it was correct ...
But now I can not print photos and barcodes ...
And there is a problem with how to connect to the printer, and any device with Bluetooth on is connected, and every time we have to click on the scanner button of the printer ... Is it possible that it displays the list of devices and we click on the printer in question?
As explained in POST 6, this function is not yet active.
For the connection, I will test and answer you as soon as possible
 

Ali Alsaedi

Member
Licensed User
Longtime User
I need to print photos and text in my new project ... Now it prints the text with your library, but the photo has a problem ... I use b4i 6.5 ...
 

Star-Dust

Expert
Licensed User
Longtime User
I need to print photos and text in my new project ... Now it prints the text with your library, but the photo has a problem ... I use b4i 6.5 ...
As indicated in post#1, post#6, post#26 and in this other thread. Forgive me if I haven't been clear enough in my previous answers. ? ? ? ?
This function is not yet active.​
Cette fonctionnalité n’est pas encore active​
Эта функция еще не активна​
Esta función aún no está activa​
Αυτή η δυνατότητα δεν είναι ακόμα ενεργή​
이 기능은 아직 활성화되지 않았습니다.​
Diese Funktion ist noch nicht aktiv​
此功能尚未激活​
תכונה זו עדיין אינה פעילה​
Tato funkce ještě není aktivní.​
هذه الوظيفة ليست نشطة بعد​
Lo msebenzi awukasebenzi​
এই ফাংশনটি এখনও সক্রিয় নয়​
Ova funkcija još nije aktivna​
 
Last edited:

Innov34

Member
Licensed User
Hi,
I have use the src of BlePeripheral2.java to try to make a new library BlePeripheral4.java to connect peripheral at a central Nordic UART
i have change :

BluetoothGattService service = new BluetoothGattService(longUUID("0001"), BluetoothGattService.SERVICE_TYPE_PRIMARY);
charRead = new BluetoothGattCharacteristic(longUUID("0003"), BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic.PROPERTY_NOTIFY, BluetoothGattCharacteristic.PERMISSION_READ);
charWrite = new BluetoothGattCharacteristic(longUUID("0002"), BluetoothGattCharacteristic.PROPERTY_WRITE, BluetoothGattCharacteristic.PERMISSION_WRITE);
charRead.addDescriptor(new BluetoothGattDescriptor(longUUID("2803"), BluetoothGattDescriptor.PERMISSION_READ | BluetoothGattDescriptor.PERMISSION_WRITE));


and in

java.util.UUID longUUID(String shortName)
return UUID.fromString("6e40" + shortName + "-b5a3-f393-e0a9-e50e24dcca9e");



I call the new library the start find ok but the central don t see the this peripheral
can you help me

best regards
Thanks
 

Star-Dust

Expert
Licensed User
Longtime User
Hi, to ask questions about how to make libraries you have to go to the appropriate part of the forum to ask questions.
This is dedicated to presenting and distributing library.

Also I believe you are wrong platform. Here it is for Apple devices running iOS. I don't see what Java is about.

If you are trying to write something for Android write your question in the appropriate part of the forum
 

Star-Dust

Expert
Licensed User
Longtime User
Hi @narek adonts ,
Unfortunately I have not made progress, it seems that the data sent is too much or too fast and is not being processed.
In debug mode it works, but extremely slowly, a printout is obtained after 10 minutes or more.

I have seen Software for iOs that work well and fast, so I am doing something wrong in the transmission of the images
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.04
  • Add ESC POS command
  • fix bug
 

Star-Dust

Expert
Licensed User
Longtime User
After 3 years of trying I realized that I was unable to print due to the old iPhone device. Today I tried with a recent iPad and the printing works fine.

Soon I will release the version that prints. Obviously the free version will not contain image printing.
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.25
  • Fix bugs
REMEMBER said:
Remember that the accepted characteristics for a printer are: 2AF0 and 2AF1
Sample:
Ble.CharatteristicName="2AF1"
Ble.connect(ID)
 
Top