บลูทูธ Android พร้อมอะแดปเตอร์เครื่องพิมพ์

ฉันมีปัญหา. ฉันมีอะแดปเตอร์เครื่องพิมพ์ bluethoot หนึ่งตัว "Bluetake BT220" และเครื่องพิมพ์หนึ่งตัว "Star DP8340S" ฉันต้องการเชื่อมต่อ bluetot bt220 ของฉันกับแอพ android ของฉัน ฉันมีการเชื่อมต่ออื่นกับเครื่องพิมพ์ม้าลาย แต่ใช้การเชื่อมต่อ สำหรับอะแดปเตอร์ bluethoot นี้ ไม่ได้เชื่อมต่อ กำลังดูเน็ตอยู่มาก ฉันเห็นว่าฉันสามารถเชื่อมต่อ bluethoot ได้โดยตรง
ฉันสามารถเชื่อมต่อกับอุปกรณ์ได้ แต่พิมพ์ไม่ได้ มีคนบอกฉันว่าจะเริ่มจากตรงไหน ข้อเสนอแนะใด ๆ ยินดีต้อนรับ

เอกสารใด ๆ อย่าลังเลที่จะถาม

ขอบคุณทุกท่านด้วยการทำให้ชีวิตง่ายขึ้น


person Delari Jesus    schedule 29.12.2013    source แหล่งที่มา


คำตอบ (1)


ฉันตอบตัวเอง แก้ไขแล้ว : ฉันเพิ่งสร้างการเชื่อมต่อ bluethoot ดังต่อไปนี้

    bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
                    BluetoothDevice bluetakebt220 = bluetoothAdapter.getRemoteDevice(obj.getMac().toString());
                    Method m;
                    BluetoothSocket mBTsocket= null;

                        m = bluetakebt220.getClass().getMethod("createRfcommSocket",
                                new Class[] { int.class });
                        // mBTsocket = (BluetoothSocket) m.invoke(bluetakebt220, 1);

                         UUID num = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
                        mBTsocket = bluetakebt220.createRfcommSocketToServiceRecord(num);
                        mBTsocket.connect();

และตอนนี้ก็แค่ต้องพิมพ์

                        String txt ="LINE 1 \n LINE 2 \n";


                        byte[] CPCLFormat = null;
                        try {
                            CPCLFormat = txt .getBytes("utf-8");
                            try {
                                 os.write(CPCLFormat);
                            } catch (Exception e) {
                                os.close();
                                e.printStackTrace();
                            }
                        } catch (UnsupportedEncodingException e1) {
                            CPCLFormat = null;
                            os.close();
                            e1.printStackTrace();
                        }



                            os.close();

ฉันหวังว่าจะช่วยได้ ขอบคุณ

person Delari Jesus    schedule 30.12.2013