hello to everybody
I have a problem with the execution of three cascaded timer. these three timers work perfectly if the device is connected in usb pc or AC and then when you unplug the cable, the code is executed until the sub reconnection, everything else stop.
Basically it works like
screen OFFthe first part of the event timer that disconnects the connection after 60 seconds, the second timer waits 10 minutes and the third timer hangs up the connection for 60 seconds and then break off and start again from the first timer until another event occurs the screen ON
This code is part of a service that is always active without disconnecting it when the device is connected to, this code works perfectly
the timers are declared in Process Globals
Here is the code in use
I have a problem with the execution of three cascaded timer. these three timers work perfectly if the device is connected in usb pc or AC and then when you unplug the cable, the code is executed until the sub reconnection, everything else stop.
Basically it works like
screen OFFthe first part of the event timer that disconnects the connection after 60 seconds, the second timer waits 10 minutes and the third timer hangs up the connection for 60 seconds and then break off and start again from the first timer until another event occurs the screen ON
This code is part of a service that is always active without disconnecting it when the device is connected to, this code works perfectly
the timers are declared in Process Globals
Here is the code in use
B4X:
Sub phev_screenOff(IntentAsIntent)
timerOn.Enabled=False
IftimerOff.IsInitialized = FalseThen
timerOff.Initialize("TimerOff", 60000)
EndIf
timerOff.Enabled=True
LogWrite("SERVIZIO - SCREEN OFF "& DateTime.Time(DateTime.Now))
End Sub
Sub TimerOff_Tick
timerOff.Enabled=False
wifi.TurnWiFiOff
data.TurnDataConnectionOff
LogWrite("SERVIZIO Sub TimerOff_Tick- connessione staccata"& DateTime.Time(DateTime.Now))
Riconnessione
End Sub
Sub Riconnessione
timerOff.Enabled=False
IftimerRic.IsInitialized = FalseThen
timerRic.Initialize("TimerRic", 60000)
EndIf
Iftempo2 = 0Then
timerRic.Enabled = False
LogWrite("SERVIZIO Sub Riconnessione - riconnessione disattivata" & tempo2)
Else
timerRic.Enabled = True
LogWrite("SERVIZIO Sub Riconnessione - Timer Riconnessione Start " & DateTime.Time(DateTime.Now))
EndIf
End Sub
Sub timerRic_Tick
timerRic.Enabled = False
VerificaConnessioneOn
IftimerUnMin.IsInitialized = FalseThen
timerUnMin.Initialize("TimerUnMin", 60000)
EndIf
timerUnMin.Enabled = True
LogWrite("SERVIZIO Sub TimerRiconnessione_Tick- TimerUnMin Start "& DateTime.Time(DateTime.Now))
End Sub
Sub timerUnMin_Tick
timerUnMin.Enabled = False
wifi.TurnWiFiOff
data.TurnDataConnectionOff
LogWrite("SERVIZIO Sub timerUnMin_Tick- TimerUnMin Stop "& DateTime.Time(DateTime.Now))
Riconnessione
End Sub
Sub VerificaConnessioneOn
wifi.TurnWiFiOn
data.TurnDataConnectionOn
LogWrite("SERVIZIO - sub verificaconnessioneON")
End Sub