Sub Process_Globals
Dim PrintBuffer As String
Dim btAdmin As BluetoothAdmin
Dim cmp20 As Serial
'Dim printer As TextWriter
Dim oPrn As dpp250
End Sub
Sub Globals
Dim Toggla As Toggle
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
btAdmin.Initialize("BlueTooth")
cmp20.Initialize("Printer")
End If
'Toggla.TurnBluetoothOn
StartPrinter
End Sub
Sub Activity_Resume
'Toggla.TurnBluetoothOn
End Sub
Sub Activity_Pause (UserClosed As Boolean)
'Toggla.TurnBluetoothOff
End Sub
Sub Printer_Connected (Success As Boolean)
If Success Then
'printer.Initialize(cmp20.OutputStream)
'printer.WriteLine(PrintBuffer)
'printer.Flush
Msgbox("Start Printed!","")
oPrn.printSelfTest( cmp20.InputStream, cmp20.OutputStream )
Msgbox("Stop Printed!","")
'printer.Close
cmp20.Disconnect
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 = cmp20.GetPairedDevices
Catch
Msgbox("Getting Paired Devices","Printer Error")
'printer.Close
cmp20.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
cmp20.ConnectInsecure(btAdmin,PairedDevices.Get(PairedDevices.GetKeyAt(0)),1)
Catch
Msgbox("Connecting","Printer Error")
'printer.Close
cmp20.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
cmp20.Connect(PairedDevices.Get(L.Get(Res)))
End If
End If
End Sub