Trying to clean up a program

dmorbelli

New Member
Licensed User
Longtime User
I am trying to modify the hello basic bt demo and when I close it out by using the back button, it closes fine, but I think that it is not disconnecting the bluetooth because when I restart the program I get this error.

error capture.jpg

here is my code so far

'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim YOYO As IOIOBT
Dim led As DigitalOutput
Dim Sms1 As PhoneSms

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.

Dim ImageView1 As ImageView
Dim btnLED As ToggleButton
Dim Label1 As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
If FirstTime Then
YOYO.Initialize(True)
YOYO.WaitForConnect()
led = YOYO.OpenDigitalOutput( 0,led.OP_NORMAL ,True) ' Enable LED_PIN for output
End If
End Sub

Sub Activity_Resume
Label1.Text =Label1.Text & ". LIB Ver: " & YOYO.GetIOIOVersion(YOYO.VER_IOIOLIB)

End Sub

Sub Activity_Pause (UserClosed As Boolean)
If UserClosed Then
led.Close
YOYO.disconnect()
Sms1.Send(5555551212,"Android Test Message!!!")
Activity.Finish
End If
End Sub

Sub btnLED_CheckedChange(Checked As Boolean)
led.Write(Not (btnLED.Checked)) ' Turn on/off stat LED, active LOW
End Sub

I think I need to put an Exit command or maybe put a button with a close or end command but I am not sure how to do this. Any help would be greatly appreciated
 
Top