...
Sub Printer_Connected (Success As Boolean)
If Success Then
Printer.Initialize2(BTConnection.OutputStream,"windows-1252") 'important to print f.e. German/French chars
PrintBuffer=Chr(27)&"t"&Chr(16)&"Hello" 'Set codepage 1252
Printer.WriteLine(PrintBuffer)
PrintBuffer=Chr(29) & Chr(86) & Chr(48)
Printer.WriteLine(PrintBuffer) '<-------- YOU FORGET THIS
Printer.Flush 'limpia la impresora
Msgbox("Printed!","")
Printer.Close
BTConnection.Disconnect 'disable this if you like
Else
.....
public static byte[] cut() {
return strTobytes("CUT\n");
}
#Region Module Attributes
#FullScreen: False
#IncludeTitle: True
#ApplicationLabel: Bluetooth POS Printing
#VersionCode: 1
#VersionName:
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#End Region
Sub Process_Globals
Dim PrintBuffer As String
Dim BtAdmin As BluetoothAdmin
Dim BTConnection As Serial
Dim Printer As TextWriter
Private NativeMe As JavaObject
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
' If FirstTime Then
' NativeMe.InitializeContext
' End If
' Dim s As String = NativeMe.RunMethod("cut", Null)
' Log(s)
If FirstTime Then
BtAdmin.Initialize("BlueTooth")
BTConnection.Initialize("Printer")
NativeMe.InitializeContext
Dim PairedDevices As Map
PairedDevices = BTConnection.GetPairedDevices
Dim l As List
Dim DeviceName, MacAddress As String
l.Initialize
For i = 0 To PairedDevices.Size - 1 'Check all devices
l.Add(PairedDevices.GetKeyAt(i))
DeviceName=PairedDevices.Getkeyat(i)
MacAddress=PairedDevices.GetValueAt(i)
Log(DeviceName & " -> " & MacAddress)
If DeviceName.Contains("Printer001") Then 'Insert the BT-Name of the printer or use the MAC address
Exit
End If
Next
BTConnection.Connect(MacAddress)
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause
End Sub
Sub Printer_Connected (Success As Boolean)
If Success Then
NativeMe.InitializeContext
Dim s As String = NativeMe.RunMethod("cut", Null)
Log(s)
' Printer.Initialize2(BTConnection.OutputStream,"windows-1252") 'important to print f.e. German/French chars
' PrintBuffer=Chr(27)&"t"&Chr(16)&"Hello world" 'Set codepage 1252
' Printer.WriteLine(PrintBuffer)
' Printer.Flush
'
' Msgbox("Printed!","")
' Printer.Close
' BTConnection.Disconnect 'disable this if you like
Else
Msgbox("No printer found...","Print error")
End If
End Sub
#If JAVA
public static byte[] cut() {
return strTobytes("CUT\n");
}
#End If
it is just printing "CUT\n"Is it not something like this?
B4X:PrintBuffer="CUT\n" Printer.WriteLine(PrintBuffer) Printer.Flush
- selectCutPagerModerAndCutPager
public static byte[] selectCutPagerModerAndCutPager(int m)
select the model of cutpage and cut the pager GS V m
Parameters:
m:0,48,all - cut;1,49,half cut
- selectCutPagerModerAndCutPager
public static byte[] selectCutPagerModerAndCutPager(int m,
int n)
select cut paper model and cut paper GS V m n
Parameters:
m:66 -
n:feed - n,half cut paper
#Region Module Attributes
#FullScreen: False
#IncludeTitle: True
#ApplicationLabel: Bluetooth POS Printing
#VersionCode: 1
#VersionName:
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#End Region
Sub Process_Globals
Dim PrintBuffer As String
Dim BtAdmin As BluetoothAdmin
Dim BTConnection As Serial
Dim Printer As TextWriter
Private NativeMe As JavaObject
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
' If FirstTime Then
' NativeMe.InitializeContext
' End If
' Dim s As String = NativeMe.RunMethod("cut", Null)
' Log(s)
If FirstTime Then
BtAdmin.Initialize("BlueTooth")
BTConnection.Initialize("Printer")
NativeMe.InitializeContext
Dim PairedDevices As Map
PairedDevices = BTConnection.GetPairedDevices
Dim l As List
Dim DeviceName, MacAddress As String
l.Initialize
For i = 0 To PairedDevices.Size - 1 'Check all devices
l.Add(PairedDevices.GetKeyAt(i))
DeviceName=PairedDevices.Getkeyat(i)
MacAddress=PairedDevices.GetValueAt(i)
Log(DeviceName & " -> " & MacAddress)
If DeviceName.Contains("Printer001") Then 'Insert the BT-Name of the printer or use the MAC address
Exit
End If
Next
BTConnection.Connect(MacAddress)
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause
End Sub
Sub Printer_Connected (Success As Boolean)
If Success Then
NativeMe.InitializeContext
Dim s As String = NativeMe.RunMethod("cut", Null)
'Dim s As strTobytes = NativeMe.RunMethod("cut", Null)
'Dim s As Byte = NativeMe.RunMethod("cut", Null)
Log(s)
Printer.Initialize2(BTConnection.OutputStream,"windows-1252") 'important to print f.e. German/French chars
PrintBuffer=Chr(27)&"t"&Chr(16)&"Hello world" 'Set codepage 1252
Printer.WriteLine(PrintBuffer)
Printer.Flush
Msgbox("Printed!","")
Printer.Close
BTConnection.Disconnect 'disable this if you like
Else
Msgbox("No printer found...","Print error")
End If
End Sub
#If JAVA
public static byte[] cut() {
return strTobytes("CUT\n");
}
#End If
src\b4a\example\main.java:569: error: cannot find symbol
return strTobytes("CUT\n");
^
symbol: method strTobytes(String)
location: class main
Chr(29) & Chr(86) & Chr(0)
Chr(27) & Chr(109)
yes, doesn't work..also tried (66) and (65)Try sending either
B4X:Chr(29) & Chr(86) & Chr(0)
or
B4X:Chr(27) & Chr(109)
directly to the printer, the second is a partial cut. Depending on the emulation of the ESC/POS, these codes may or may not work for you.
writeDataByYouself (commands As List, tag As Object)
Logger connected to: BMXC K107
--------- beginning of system
--------- beginning of main
** Activity (main) Pause, UserClosed = false **
java.lang.Exception: Sub activity_pause signature does not match expected signature.
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
binder connected
POS_onBind()
POS_onSuccess(BDconnectBtPort)
** Activity (main) Pause, UserClosed = false **
Looks like you have a connection... Looks GOOD.POS_onSuccess(BDconnectBtPort)
yes, printing and cut the paper when connected by USB to win7Hi there..
did you installed first on windows ?
New POS Printer (at chinese model..) have settings at driver properties (at windows)- that you must turn on like auto cutter... seems like my mine pos-80c but your's bluetooth..
Looks like you have a connection... Looks GOOD.
What is the code you are using to connect to this printer?
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
BtAdmin.Initialize("BlueTooth")
BTConnection.Initialize("Printer")
Dim PairedDevices As Map
PairedDevices = BTConnection.GetPairedDevices
Dim l As List
Dim DeviceName, MacAddress As String
l.Initialize
For i = 0 To PairedDevices.Size - 1 'Check all devices
l.Add(PairedDevices.GetKeyAt(i))
DeviceName=PairedDevices.Getkeyat(i)
MacAddress=PairedDevices.GetValueAt(i)
Log(DeviceName & " -> " & MacAddress)
If DeviceName.Contains("Printer001") Then 'Insert the BT-Name of the printer or use the MAC address
'Printer001 -> DC:0D:30:06:98:71
Exit
End If
Next
BTConnection.Connect(MacAddress)
End If
End Sub
pos.BDconnectBtPort("DC:0D:30:06:98:71","BDconnectBtPort")