mirror of
https://github.com/cheveguerra/FLP_2.0.git
synced 2026-04-17 19:36:42 +00:00
Cambio de puerto
This commit is contained in:
36
Starter.bas
36
Starter.bas
@@ -14,63 +14,44 @@ Sub Process_Globals
|
||||
'These variables can be accessed from all modules.
|
||||
Public rp As RuntimePermissions 'Para obtener permisos android 6+
|
||||
Public FLP As FusedLocationProvider 'Para Tracker
|
||||
Dim ruta As String
|
||||
Dim reqManager As DBRequestManager
|
||||
Dim cmd As DBCommand
|
||||
Dim Timer1 As Timer
|
||||
Dim interval As Int = 600 '600 segs (10 mins)
|
||||
Dim interval As Int = 1800 '1800 segs (30 mins)
|
||||
Dim UUC As Location
|
||||
Dim run As Int = 0 'ignore
|
||||
Dim devModel As String
|
||||
Dim lastLocUpdate As String = 0
|
||||
Dim logger As Boolean = True
|
||||
' Dim FLPStatus As String
|
||||
End Sub
|
||||
|
||||
Sub Service_Create
|
||||
'This is the program entry point.
|
||||
'This is a good place to load resources that are not specific to a single activity.
|
||||
ruta = File.DirInternal 'Ruta de la base de datos por defecto.
|
||||
If File.ExternalWritable Then ruta = rp.GetSafeDirDefaultExternal("") 'Si podemos escribir a la tarjeta, cambiamos la ruta.
|
||||
If Not(File.Exists(ruta, "gps_hist.db")) Then File.Copy(File.DirAssets, "gps_hist.db", ruta, "gps_hist.db") 'Si no existe el archivo de la base de datos, lo copiamos.
|
||||
If Subs.gps_hist.IsInitialized = False Then Subs.gps_hist.Initialize(ruta, "gps_hist.db", True)
|
||||
Subs.gps_hist.ExecNonQuery("CREATE TABLE IF NOT EXISTS BITACORA(RUTA TEXT, TEXTO TEXT, FECHA TEXT)")
|
||||
If logger Then Log(ruta)
|
||||
Subs.revisaBD
|
||||
CallSubDelayed(FirebaseMessaging, "SubscribeToTopics") 'Para FirebaseMessaging
|
||||
End Sub
|
||||
|
||||
Sub Service_Start (StartingIntent As Intent)
|
||||
Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
|
||||
' reqManager.Initialize(Me, "http://10.0.0.205:1782")
|
||||
reqManager.Initialize(Me, "http://keymon.lat:1782")
|
||||
reqManager.Initialize(Me, "http://keymon.lat:1781")
|
||||
Timer1.Initialize("Timer1", interval * 1000)
|
||||
Timer1.Enabled = True
|
||||
UUC.Initialize
|
||||
UUC.Accuracy = 1000
|
||||
Subs.getPhnId
|
||||
Subs.bitacora($"Starter - Service_Start"$)
|
||||
' Subs.gps_hist.ExecNonQuery($"insert into BITACORA (RUTA, TEXTO, FECHA) values ('${devModel}', 'Starter - Service_Start', '${Subs.fechaKMT(DateTime.now)}')"$)
|
||||
StartService(Tracker)
|
||||
StartReceiverAt(Tracker, DateTime.Now + 30 * DateTime.TicksPerMinute, True)
|
||||
StartServiceAt(Tracker, DateTime.Now + 30 * DateTime.TicksPerMinute, True)
|
||||
#if RELEASE
|
||||
logger = False
|
||||
#end if
|
||||
Subs.revisaYmandaUUC
|
||||
End Sub
|
||||
|
||||
Private Sub Timer1_Tick
|
||||
CallSubDelayed(Tracker, "StartFLP")
|
||||
Subs.bitacora($"TimerTick - tiempo trans: ${((DateTime.now - lastLocUpdate)/1000)}"$)
|
||||
' Subs.gps_hist.ExecNonQuery($"insert into BITACORA (RUTA, TEXTO, FECHA) values ('${devModel}', 'TimerTick - tiempo trans: ${((DateTime.now - lastLocUpdate)/1000)}', '${Subs.fechaKMT(DateTime.now)}')"$)
|
||||
If logger Then Log("Next run " & DateTime.Time(DateTime.Now + interval * 1000))
|
||||
' Log($"|${Tracker.FLP.IsInitialized}|${Tracker.FLP.GetLastKnownLocation.IsInitialized}|"$)If DateTime.DateForm
|
||||
|
||||
'Si ya pasaron mas de 15 minutos (900 segs) desde la ultima actualización, entonces mandamos UUC.
|
||||
If ((DateTime.now - lastLocUpdate)/1000) > (interval * 1.5) Then
|
||||
If logger Then LogColor($"Mandamos "Ultima Ubicacion Conocida" porque no se ha enviado en ${(interval * 1.5)} segs."$, Colors.red)
|
||||
Subs.bitacora("TimerTick, Tiempo mayor a 1.5, iniciamos StartFLP y guardamos UUC")
|
||||
' Subs.gps_hist.ExecNonQuery($"insert into BITACORA (RUTA, TEXTO, FECHA) values ('${devModel}', 'TimerTick, Tiempo mayor a 1.5, iniciamos StartFLP y guardamos UUC', '${Subs.fechaKMT(DateTime.now)}')"$)
|
||||
CallSubDelayed2(Tracker, "dameUltimaUbicacionConocida", UUC)
|
||||
End If
|
||||
Subs.borraArribaDe10000Bitacora
|
||||
' Log("TIMER1: " & Timer1)
|
||||
Subs.borraArribaDeXXXBitacora(3000)
|
||||
End Sub
|
||||
|
||||
Sub Service_TaskRemoved
|
||||
@@ -89,6 +70,7 @@ End Sub
|
||||
|
||||
Sub restartTracker
|
||||
Log("Llamamos RESTART-TRACKER")
|
||||
Subs.bitacora("Llamamos RESTART-TRACKER")
|
||||
StopService(Tracker)
|
||||
Sleep(1000)
|
||||
StartService(Tracker)
|
||||
|
||||
Reference in New Issue
Block a user