Search code examples
androidprintingbluetoothbixolon-printer

Android barcode printing with Bixolon SPP-R200II


I need to print a barcode in a mobile bluetooth printer brand “Bixolon” model “SPP-R200II” from an android application. Using the Bixolon SDK for Android does work for a Samsung SII but not for a Motorola moto G G2. I decided not using the SDK, instead I am sending commands to the printer based on the “unified command manual” by Bixolon. I am using these lines:

String codigo=”1234567894”;
int GS=29;
int k=107;
int m=5;
byte[] codigobytes=codigo.getBytes();
outputstream.write((byte)GS);
outputstream.write((byte)k);
outputstream.write((byte)m);
outputstream.write(codigobytes);

Based on the manual this command should print an “ITF” barcode but it does not. Connection with printer was successfully stablished; even I can print text but not barcodes with this command. Has anybody had better luck in printing barcodes with this method and printer? I appreciate your help and comments.


Solution

  • This is the code that worked fine in my app:

            ByteArrayOutputStream baos=new ByteArrayOutputStream();
            String barcode="12345";
            int GS=29;
            int k=107;
            int m=73;   //73 code128
            int n=barcode.length(); //code length
            int h=104;
            int HH=72;
            int Hn=2;
            int height=70;
    
            // code height=80
            baos.write((byte) GS);
            baos.write((byte) h);
            baos.write((byte)height);
    
            //width of each bar in barcode to the minimum
              int ESC=29;
              int w=119;
              int n=2;
              baos.write((byte)ESC);
              baos.write((byte)w);
              baos.write((byte)n);
    
            //Print label below barcode
            baos.write((byte)GS);
            baos.write((byte)HH);
            baos.write((byte)Hn);
    
            //Print barcode type Code 128
            byte[] codebytes=barcode.getBytes();
            baos.write((byte)GS);
            baos.write((byte)k);
            baos.write((byte)m);
            baos.write((byte)n);
            baos.write(codebytes);
        // Paper feed
            int ESC=27;
            int d=100;
            int n=2;
            baos.write((byte)ESC);
            baos.write((byte)d);
            baos.write((byte)n);