B4i Library iSD BLE Printer

Discussion in 'iOS Libraries' started by Star-Dust, Mar 10, 2019.

  1. Star-Dust

    Star-Dust Expert Licensed User

    I am happy to present my library to print with Iphone (and iPad) with Bluetooh (BLE). At the moment I can not print the images, but I'm working on it. If you want to have the activation code (Freeing all the functions) contact me in private.

    (Here for B4J, Here for B4A)

    This version requires an activation code. If you do not have a code then it will work in DEMO mode and you will only be able to print every 4 minutes.


    iSD_BLE_Printer

    Author: Star-Dust
    Version: 0.02
    • BLE_Printer
      • Events:
        • Connected (services As List)
        • Disconnected
        • PrinterFound (Name As String, ID As String)
      • 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))
        • Class_Globals As NSString*
        • Connect (ID As NSString*) As NSString*
        • getisConcect As BOOL
        • 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*
        • PrintBitmap2 (bmp As B4IBitmap*, Shift As Int) As NSString*
        • PrintBitmap (bmp As B4IBitmap*, dotsAtTheLeft As Int) As NSString*
        • ScanPrinter As NSString*
        • 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
        • IsInitialized As BOOL
          Verifica se l'oggetto sia stato inizializzato.
      • Properties:
        • isConcect As BOOL [read only]
    • 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_DoubleWideHight As NSString*
        • FontA_Normal As NSString*
        • FontB_Bold As NSString*
        • FontB_DoubleHight As NSString*
        • FontB_DoubleWide As NSString*
        • FontB_DoubleWideHight As NSString*
        • FontB_Normal As NSString*
        • InitializePrinter As NSString*
        • NoUnderline As NSString*
        • Underline1 As NSString*
        • Underline2 As NSString*
      • Functions:
        • Process_Globals As NSString*
          Code module
          Subs in this code module will be accessible from all modules.
    • Encoding
      • Fields:
        • 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.
     

    Attached Files:

    Last edited: Mar 12, 2019
  2. Star-Dust

    Star-Dust Expert Licensed User

    Sample:

    Code:
    Private Sub Application_Start (Nav As NavigationController)
        
    'SetDebugAutoFlushLogs(True) 'Uncomment if program crashes before all logs are printed.
        NavControl = Nav
        Page1.Initialize(
    "Page1")
        Page1.Title = 
    "Page 1"
        Page1.RootPanel.Color = 
    Colors.White
        NavControl.ShowPage(Page1)
        Page1.RootPanel.LoadLayout(
    "Layout1")
        
        Ble.Initialize(Me,
    "Ble","")
        ButtonSend.Visible=
    False
        ButtonImage.Visible=
    False
    End Sub
    METHOD
    Code:
    Sub ButtonScan_Click
        Ble.ScanPrinter
        ButtonSend.Visible=
    False
        ButtonImage.Visible=
    False
    End Sub

    Sub ButtonSend_Click
        Ble.Writeline(ESC_POS.DoubleOn & 
    "TEST OF PRINT")
    End Sub

    EVENT
    Code:
    Sub Ble_PrinterFound(Name As StringID As String)
        LabelInfo.Text=
    $"Fondi printer: ${Name}"$
        Ble.connect(
    ID)
    End Sub

    Sub Ble_Connected(services As List)
        ButtonSend.Visible=
    True
        ButtonImage.Visible=
    True
    End Sub

    Sub Ble_Disconnected
        ButtonSend.Visible=
    False
        ButtonImage.Visible=
    False
    End Sub
     
  3. jahswani

    jahswani Active Member Licensed User

    What’s the donation amount ?
     
  4. Star-Dust

    Star-Dust Expert Licensed User

    Dear @jahswani ,
    As long as I do not add the images will be free donation, there will not be a minimum limit. When I add the PrintBitmap method, contact me privately, as specified in post # 1
     
  5. jahswani

    jahswani Active Member Licensed User

    What about this method ?
    • PrintBitmap (bmp As B4IBitmap*, Shift As Int) As NSString*
     
  6. Star-Dust

    Star-Dust Expert Licensed User

    Ignore it, it's not working yet
     
  7. Star-Dust

    Star-Dust Expert Licensed User

    Finally I managed to print in graphics with BLE. It is a simple chessboard, but that makes the idea of potential.
    Even if it is a step forward I am still far from printing an image.

    The BLE protocol is giving me a hard time, the packages must be small and the images sectioned to be transmitted .... we'll see if I succeed

    upload_2019-3-13_10-1-19.png
     
    Filippo and Erel like this.
  8. jahswani

    jahswani Active Member Licensed User

    Good work. Just continue your quest. Good luck...
     
  9. jahswani

    jahswani Active Member Licensed User

    I tried the current version. It(s not compiling.
    Code:
    B4i Version : 4.81
    Analyse du code.    (
    0.00s)
    Compilation du code.    (
    0.10s)
    Compilation du code des layouts.    (
    0.01s)
    Compilation du code du débogueur.    (
    3.02s)
    Etablissement du projet Xcode    (
    0.63s)
    Envoi de données au 
    'Remote Compiler'.    Error
    B4i line: 48
    Ble.Initialize(Me,\
    no visible @interface 
    for 'b4i_ble_printer' declares the selector '_initialize::::'

    Out: Build 
    settings from command line:
        ARCHS = x86_64
        CODE_SIGNING_REQUIRED = NO
        CONFIGURATION_BUILD_DIR = /Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user 
    id>/Payload
        PRODUCT_NAME = BLE Printer
        SDKROOT = iphonesimulator11
    .2

    === BUILD TARGET B4iProject OF PROJECT B4iProject WITH CONFIGURATION Release ===

    Check dependencies

    Create product structure
    /bin/mkdir -p /Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user 
    id>/Payload/BLE\ Printer.app

    CompileC build/B4iProject.build/Release-iphonesimulator/B4iProject.build/Objects-normal/x86_64/b4i_main.o B4iProject/b4i_main.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_
    0.compiler
        cd /Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user 
    id>
        export LANG=en_US.US-ASCII
        export 
    PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch x86_64 -fmessage-length=
    0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -gmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/var/folders/dh/pfp02c51141fx0vsd77svxwh0000gn/C/org.llvm.clang/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DNS_BLOCK_ASSERTIONS=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.2.sdk -fasm-blocks -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -mios-simulator-version-min=8.0 -fvisibility=hidden -Wno-sign-conversion -Wno-infinite-recursion -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -fobjc-abi-version=2 -fobjc-legacy-dispatch -iquote /Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/BLE\ Printer-generated-files.hmap -I/Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/BLE\ Printer-own-target-headers.hmap -I/Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/BLE\ Printer-all-target-headers.hmap -iquote /Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/BLE\ Printer-project-headers.hmap -I/Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/Payload/include -I/Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/DerivedSources/x86_64 -I/Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/DerivedSources -F/Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/Payload -F../../Libs -MMD -MT dependencies -MF /Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/Objects-normal/x86_64/b4i_main.d --serialize-diagnostics /Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/Objects-normal/x86_64/b4i_main.dia -c /Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/B4iProject/b4i_main.m -o /Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/Objects-normal/x86_64/b4i_main.o
    /Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user 
    id>/B4iProject/b4i_main.m:58:12: error: no visible @interface for 'b4i_ble_printer' declares the selector '_initialize::::'
    [self._ble _initialize:self.bi :self :@"Ble" :@""];
     ~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1 error generated.

    CompileC build/B4iProject.build/Release-iphonesimulator/B4iProject.build/Objects-normal/x86_64/main.o B4iProject/main.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_
    0.compiler
        cd /Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user 
    id>
        export LANG=en_US.US-ASCII
        export 
    PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch x86_64 -fmessage-length=
    0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -gmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/var/folders/dh/pfp02c51141fx0vsd77svxwh0000gn/C/org.llvm.clang/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DNS_BLOCK_ASSERTIONS=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.2.sdk -fasm-blocks -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -mios-simulator-version-min=8.0 -fvisibility=hidden -Wno-sign-conversion -Wno-infinite-recursion -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -fobjc-abi-version=2 -fobjc-legacy-dispatch -iquote /Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/BLE\ Printer-generated-files.hmap -I/Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/BLE\ Printer-own-target-headers.hmap -I/Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/BLE\ Printer-all-target-headers.hmap -iquote /Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/BLE\ Printer-project-headers.hmap -I/Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/Payload/include -I/Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/DerivedSources/x86_64 -I/Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/DerivedSources -F/Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/Payload -F../../Libs -MMD -MT dependencies -MF /Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/Objects-normal/x86_64/main.d --serialize-diagnostics /Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/Objects-normal/x86_64/main.dia -c /Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/B4iProject/main.m -o /Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/Objects-normal/x86_64/main.o

    CompileC build/B4iProject.build/Release-iphonesimulator/B4iProject.build/Objects-normal/x86_64/LS_layout1.o B4iProject/LS_layout1.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_
    0.compiler
        cd /Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user 
    id>
        export LANG=en_US.US-ASCII
        export 
    PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch x86_64 -fmessage-length=
    0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -gmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/var/folders/dh/pfp02c51141fx0vsd77svxwh0000gn/C/org.llvm.clang/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DNS_BLOCK_ASSERTIONS=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.2.sdk -fasm-blocks -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -mios-simulator-version-min=8.0 -fvisibility=hidden -Wno-sign-conversion -Wno-infinite-recursion -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -fobjc-abi-version=2 -fobjc-legacy-dispatch -iquote /Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/BLE\ Printer-generated-files.hmap -I/Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/BLE\ Printer-own-target-headers.hmap -I/Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/BLE\ Printer-all-target-headers.hmap -iquote /Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/BLE\ Printer-project-headers.hmap -I/Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/Payload/include -I/Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/DerivedSources/x86_64 -I/Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/DerivedSources -F/Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/Payload -F../../Libs -MMD -MT dependencies -MF /Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/Objects-normal/x86_64/LS_layout1.d --serialize-diagnostics /Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/Objects-normal/x86_64/LS_layout1.dia -c /Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/B4iProject/LS_layout1.m -o /Users/jahswant/Documents/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/Objects-normal/x86_64/LS_layout1.o


    Error: ** BUILD FAILED **


    The following build commands failed:
        CompileC build/B4iProject.build/Release-iphonesimulator/B4iProject.build/Objects-normal/x86_64/b4i_main.o B4iProject/b4i_main.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_
    0.compiler
    (
    1 failure)
     
  10. Star-Dust

    Star-Dust Expert Licensed User

    Frankly I don't understand what error it is. I'll do some tests
     
  11. jahswani

    jahswani Active Member Licensed User

    It seems like it’s requesting different parameters on the initialize method. Please check. The method is also difficult in the .a file
     
  12. jahswani

    jahswani Active Member Licensed User

    Any clue ?
     
  13. Star-Dust

    Star-Dust Expert Licensed User

    I used B4I 5.50 for this library. You are using 4.81, maybe it depends on this because it seems that it doesn't find the initialize method
     
  14. MitchBu

    MitchBu Active Member Licensed User

    Star-Dust, congratulations for your effort.

    I am considering porting my present Android app to iOS with B4i, but I absolutely need quality printing.

    Any idea of the resolution of the printed output ?

    Have you completed bitmap printing ? At which practical resolution ?

    You may want to add a "fit to paper" option in case the picture is too big.
     
  15. Star-Dust

    Star-Dust Expert Licensed User

    unfortunately at the moment I did not get a good press, but I suspended temporarily because I have a more urgent project. I will resume soon
     
  16. MitchBu

    MitchBu Active Member Licensed User

    Good luck with your present project. Looking forward to see you back on iOS. Such a library is needed.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice