#Region Project Attributes
#ApplicationLabel: GSM Modem Solar
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#BridgeLogger: True
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: False
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private bt As Serial
Private ast As AsyncStreams
Public timer As Timer
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private btnback As Button
Private lbldis As Label
Private imgblue As ImageView
Private imgclock As ImageView
Private imgsetting As ImageView
Private imgsolar As ImageView
Private imgwire As ImageView
Private Label2 As Label
Private Label3 As Label
Private Label4 As Label
Private Label5 As Label
Private pairestr As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("solar")
bt.Initialize("bt")
StopService(Starter)
timer.Initialize("timer",5000)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
If UserClosed Then
bt.Disconnect
timer.Enabled = False
StopService(Starter)
End If
End Sub
Sub timer_Tick
timer.Enabled = False
If Starter.connected = False Then
ProgressDialogShow2("Reconnecting to Bluetooth....",False)
Do While Starter.connected = False
bt.Connect(pairestr)
Sleep(2000)
Loop
End If
End Sub
Sub bt_Connected (Success As Boolean)
If Success Then
ast.Initialize(bt.InputStream,bt.OutputStream,"ast")
StartService(Starter)
ProgressDialogHide
End If
End Sub
Sub visiblview(stat As Boolean)
If stat = True Then
imgblue.Visible = False
imgclock.Visible = False
imgsetting.Visible = False
imgsolar.Visible = False
imgwire.Visible = False
Label2.Visible = False
Label3.Visible = False
Label4.Visible = False
Label5.Visible = False
lbldis.Visible = True
btnback.Visible = True
Else
imgblue.Visible = True
imgclock.Visible = True
imgsetting.Visible = True
imgsolar.Visible = True
imgwire.Visible = True
Label2.Visible = True
Label3.Visible = True
Label4.Visible = True
Label5.Visible = True
lbldis.Visible = False
btnback.Visible = False
End If
End Sub
Sub btnback_Click
visiblview(False)
End Sub
Sub imgsolar_Click
visiblview(True)
End Sub
Sub imgsetting_Click
End Sub
Sub imgclock_Click
End Sub
Sub imgblue_Click
Dim PairedDevices As Map
PairedDevices = bt.GetPairedDevices
Dim l As List
l.Initialize
For i = 0 To PairedDevices.Size - 1
l.Add(PairedDevices.GetKeyAt(i))
Next
Dim res As Int
res = InputList(l, "Choose device", -1) 'show list with paired devices
If res <> DialogResponse.CANCEL Then
bt.Connect(PairedDevices.Get(l.Get(res))) 'convert the name to mac address
pairestr = PairedDevices.Get(l.Get(res))
End If
End Sub