Sub Process_Globals
Dim PrintBuffer As String
Dim btAdmin As BluetoothAdmin
Dim dpp350 As Serial
Dim printer As TextWriter
End Sub
Sub Globals
Dim Toggla As Toggle
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
btAdmin.Initialize("BlueTooth")
dpp350.Initialize("Printer")
End If
Activity.LoadLayout("MainMenu")
End Sub
Sub Activity_Resume
StartPrinter
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Printer_Connected (Success As Boolean)
If Success Then
printer.Initialize(dpp350.OutputStream)
printer.WriteLine(Chr(27) & "@")
printer.WriteLine(Chr(27) & "T")
printer.WriteLine("TESTESSSSSSSSSSSSSS")
printer.Flush
printer.Close
dpp350.Disconnect
Msgbox("Success","sucesso")
Else
If Msgbox2("", "Printer Error","Reprint","Cancel","",Null) = DialogResponse.POSITIVE Then
StartPrinter
End If
End If
End Sub
Sub StartPrinter
Dim PairedDevices As Map
Dim L As List
Dim Res As Int
ToastMessageShow("Printing.....",True)
PairedDevices.Initialize
Try
PairedDevices = dpp350.GetPairedDevices
Catch
Msgbox("Getting Paired Devices","Printer Error")
printer.Close
dpp350.Disconnect
End Try
If PairedDevices.Size = 0 Then
Msgbox("Error Connecting to Printer - Printer Not Found","")
Return
End If
If PairedDevices.Size = 1 Then
Try
dpp350.ConnectInsecure(btAdmin,PairedDevices.Get(PairedDevices.GetKeyAt(0)),1)
Catch
Msgbox("Connecting","Printer Error")
printer.Close
dpp350.Disconnect
End Try
Else
L.Initialize
For i = 0 To PairedDevices.Size - 1
L.Add(PairedDevices.GetKeyAt(i))
Next
Res = InputList(L, "Choose device", -1)
If Res <> DialogResponse.CANCEL Then
dpp350.Connect(PairedDevices.Get(L.Get(Res)))
End If
End If
End Sub