mirror of
https://github.com/cheveguerra/FLP_2.0.git
synced 2026-04-17 19:36:42 +00:00
28/9/23 - Modificaciones para que mande la ubicación si no hay cambios durante 15 minutos.
This commit is contained in:
25
FLP-ML.b4a
25
FLP-ML.b4a
@@ -38,13 +38,23 @@ Version=12.5
|
|||||||
#Region Project Attributes
|
#Region Project Attributes
|
||||||
#ApplicationLabel: FLP 2.0
|
#ApplicationLabel: FLP 2.0
|
||||||
#VersionCode: 1
|
#VersionCode: 1
|
||||||
#VersionName: 3.07.07
|
#VersionName: 3.09.27
|
||||||
'SupportedOrientations possible values: unspecified, landscape or portrait.
|
'SupportedOrientations possible values: unspecified, landscape or portrait.
|
||||||
#SupportedOrientations: unspecified
|
#SupportedOrientations: unspecified
|
||||||
#CanInstallToExternalStorage: False
|
#CanInstallToExternalStorage: False
|
||||||
' #AdditionalJar: com.android.support:support-v4
|
' #AdditionalJar: com.android.support:support-v4
|
||||||
#AdditionalJar: com.google.android.gms:play-services-location
|
#AdditionalJar: com.google.android.gms:play-services-location
|
||||||
#BridgeLogger:True
|
#BridgeLogger:True
|
||||||
|
'###########################################################################################################
|
||||||
|
'###################### PULL #############################################################
|
||||||
|
'Ctrl + click ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=git&Args=pull
|
||||||
|
'###########################################################################################################
|
||||||
|
'###################### PUSH #############################################################
|
||||||
|
'Ctrl + click ide://run?file=%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe&Args=github&Args=..\..\
|
||||||
|
'###########################################################################################################
|
||||||
|
'###################### PUSH TORTOISE GIT #########################################################
|
||||||
|
'Ctrl + click ide://run?file=%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe&Args=TortoiseGitProc&Args=/command:commit&Args=/path:"./../"&Args=/closeonend:2
|
||||||
|
'###########################################################################################################
|
||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
#Region Activity Attributes
|
#Region Activity Attributes
|
||||||
@@ -65,7 +75,7 @@ End Sub
|
|||||||
|
|
||||||
Sub Globals
|
Sub Globals
|
||||||
'These global variables will be redeclared each time the activity is created.
|
'These global variables will be redeclared each time the activity is created.
|
||||||
Private Button1 As Button
|
Private b_pong As Button
|
||||||
Private et_id As EditText
|
Private et_id As EditText
|
||||||
Private b_guardarId As Button
|
Private b_guardarId As Button
|
||||||
Private l_coords As Label
|
Private l_coords As Label
|
||||||
@@ -79,7 +89,7 @@ Sub Activity_Create(FirstTime As Boolean)
|
|||||||
Subs.getPhnId
|
Subs.getPhnId
|
||||||
et_id.Text = Starter.devModel.trim
|
et_id.Text = Starter.devModel.trim
|
||||||
getSSID
|
getSSID
|
||||||
Button1.Left = Round(Activity.Width/2)-(Button1.Width/2)
|
b_pong.Left = Round(Activity.Width/2)-(b_pong.Width/2)
|
||||||
l_id.Left = (Activity.Width / 2) - (l_id.Width / 2)
|
l_id.Left = (Activity.Width / 2) - (l_id.Width / 2)
|
||||||
l_lastUpdate.Left = (Activity.Width / 2) - (l_lastUpdate.Width / 2)
|
l_lastUpdate.Left = (Activity.Width / 2) - (l_lastUpdate.Width / 2)
|
||||||
b_guardarId.Left = (Activity.Width / 2) - (b_guardarId.Width / 2)
|
b_guardarId.Left = (Activity.Width / 2) - (b_guardarId.Width / 2)
|
||||||
@@ -110,8 +120,9 @@ Sub Activity_Pause (UserClosed As Boolean)
|
|||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub Button1_Click
|
Sub b_pong_Click
|
||||||
Subs.mandaLocAServer(laUbicacion, Starter.devModel.Trim)
|
CallSubDelayed(Tracker, "StartFLP")
|
||||||
|
If laUbicacion.IsInitialized Then Subs.mandaLocAServer(laUbicacion, Starter.devModel.Trim)
|
||||||
Dim params As Map = CreateMap("topic": FirebaseMessaging.Sprvsr,"title":"Prueba Trckr", "body":"Prueba Trckr", "d":Starter.devModel, "t":"pong")
|
Dim params As Map = CreateMap("topic": FirebaseMessaging.Sprvsr,"title":"Prueba Trckr", "body":"Prueba Trckr", "d":Starter.devModel, "t":"pong")
|
||||||
CallSubDelayed2(FirebaseMessaging, "SendMessage",params)
|
CallSubDelayed2(FirebaseMessaging, "SendMessage",params)
|
||||||
If Starter.logger Then Log("Start wifi scan")
|
If Starter.logger Then Log("Start wifi scan")
|
||||||
@@ -119,7 +130,7 @@ Sub Button1_Click
|
|||||||
Wait For WiFi_ScanDone (Results() As String, Count As Int)
|
Wait For WiFi_ScanDone (Results() As String, Count As Int)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub Button1_LongClick
|
Sub b_pong_LongClick
|
||||||
copiaDB
|
copiaDB
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@@ -193,7 +204,7 @@ Private Sub b_guardarId_Click
|
|||||||
et_id.Text = Starter.devModel.Trim
|
et_id.Text = Starter.devModel.Trim
|
||||||
If Starter.logger Then Log(Starter.devModel.Trim)
|
If Starter.logger Then Log(Starter.devModel.Trim)
|
||||||
End If
|
End If
|
||||||
If Tracker.FLP.IsInitialized Then Subs.mandaLocAServer(laUbicacion, Starter.devModel.Trim)
|
If laUbicacion.IsInitialized Then Subs.mandaLocAServer(laUbicacion, Starter.devModel.Trim)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub ponCoords
|
Sub ponCoords
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ ModuleClosedNodes1=
|
|||||||
ModuleClosedNodes2=
|
ModuleClosedNodes2=
|
||||||
ModuleClosedNodes3=1
|
ModuleClosedNodes3=1
|
||||||
ModuleClosedNodes4=
|
ModuleClosedNodes4=
|
||||||
ModuleClosedNodes5=
|
ModuleClosedNodes5=2,3
|
||||||
ModuleClosedNodes6=2,3,4,5,6,7,8,9,10,11,12,13,16
|
ModuleClosedNodes6=2,3,4,5,6,7,8,9,10,11,12,13
|
||||||
ModuleClosedNodes7=7,8
|
ModuleClosedNodes7=9,11
|
||||||
NavigationStack=Subs,ConvertMillisecondsToString,179,0,Main,actualizaLabelUU,173,5,Main,b_guardarId_Click,142,0,Visual Designer,Layout.bal,-100,6,Main,Globals,36,1,Main,Activity_Create,42,6,Starter,Timer1_Tick,54,0,Starter,Process_Globals,15,0,Subs,fechaKMT,141,0,Subs,mandaLocAServer,171,6
|
NavigationStack=FirebaseMessaging,SendMessage,142,0,Starter,Process_Globals,5,0,Starter,Service_Start,46,0,Tracker,StartFLP,76,0,Starter,Timer1_Tick,55,6,Tracker,dameUltimaUbicacionConocida,102,1,NotificationService,NotiMon_NotificationPosted,81,6,Tracker,flp_LocationChanged,135,6,Tracker,StopFLP,128,0,Main,b_pong_Click,75,0
|
||||||
SelectedBuild=0
|
SelectedBuild=0
|
||||||
VisibleModules=5,2,7,3,6,4
|
VisibleModules=5,2,7,3,6,4
|
||||||
|
|||||||
BIN
Files/layout.bal
BIN
Files/layout.bal
Binary file not shown.
@@ -72,7 +72,7 @@ Sub Service_Destroy
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub NotiMon_NotificationPosted (SBN As StatusBarNotification)
|
Sub NotiMon_NotificationPosted (SBN As StatusBarNotification)
|
||||||
If not(Tracker.FLP.IsInitialized) then StartService(Tracker)
|
If Not(Tracker.FLP.IsInitialized) Then StartService(Tracker) 'Si el servicio no esta corriendo, lo iniciamos.
|
||||||
Private logger As Boolean = True
|
Private logger As Boolean = True
|
||||||
' Log("-= Notificacion recibida =-")
|
' Log("-= Notificacion recibida =-")
|
||||||
If SBN.PackageName = "com.whatsapp" Then
|
If SBN.PackageName = "com.whatsapp" Then
|
||||||
@@ -84,7 +84,8 @@ Sub NotiMon_NotificationPosted (SBN As StatusBarNotification)
|
|||||||
' Si recibimos un mensaje con la palabra "donde", "Donde" o "bien", entonces mandamos la última ubicación conocida.
|
' Si recibimos un mensaje con la palabra "donde", "Donde" o "bien", entonces mandamos la última ubicación conocida.
|
||||||
If SBN.Message.Contains("donde") Or SBN.Message.Contains("Donde") Or SBN.Message.Contains("bien") Then 'Si el mensaje contiene "#NS" y tiene un segundo parametro ...
|
If SBN.Message.Contains("donde") Or SBN.Message.Contains("Donde") Or SBN.Message.Contains("bien") Then 'Si el mensaje contiene "#NS" y tiene un segundo parametro ...
|
||||||
If esMensajeWAValido(SBN) Then
|
If esMensajeWAValido(SBN) Then
|
||||||
CallSub2(Tracker, "dameUltimaUbicacionConocida", Starter.UUC)
|
CallSubDelayed(Tracker, "StartFLP")
|
||||||
|
CallSubDelayed2(Tracker, "dameUltimaUbicacionConocida", Starter.UUC)
|
||||||
Log("Mandamos a Server")
|
Log("Mandamos a Server")
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|||||||
12
Starter.bas
12
Starter.bas
@@ -18,12 +18,13 @@ Sub Process_Globals
|
|||||||
Dim reqManager As DBRequestManager
|
Dim reqManager As DBRequestManager
|
||||||
Dim cmd As DBCommand
|
Dim cmd As DBCommand
|
||||||
Dim Timer1 As Timer
|
Dim Timer1 As Timer
|
||||||
Dim interval As Int = 60 '600 segs (10 mins)
|
Dim interval As Int = 600 '600 segs (10 mins)
|
||||||
Dim UUC As Location
|
Dim UUC As Location
|
||||||
Dim run As Int = 0 'ignore
|
Dim run As Int = 0 'ignore
|
||||||
Dim devModel As String
|
Dim devModel As String
|
||||||
Dim lastLocUpdate As String = 0
|
Dim lastLocUpdate As String = 0
|
||||||
Dim logger As Boolean = True
|
Dim logger As Boolean = True
|
||||||
|
Dim FLPStatus As String
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub Service_Create
|
Sub Service_Create
|
||||||
@@ -51,14 +52,15 @@ Sub Service_Start (StartingIntent As Intent)
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub Timer1_Tick
|
Private Sub Timer1_Tick
|
||||||
' ToastMessageShow("Timer",False)
|
CallSubDelayed(Tracker, "StartFLP")
|
||||||
If logger Then Log("Next run " & DateTime.Time(DateTime.Now + interval * 1000))
|
If logger Then Log("Next run " & DateTime.Time(DateTime.Now + interval * 1000))
|
||||||
' Log($"|${Tracker.FLP.IsInitialized}|${Tracker.FLP.GetLastKnownLocation.IsInitialized}|"$)If DateTime.DateForm
|
' Log($"|${Tracker.FLP.IsInitialized}|${Tracker.FLP.GetLastKnownLocation.IsInitialized}|"$)If DateTime.DateForm
|
||||||
CallSub2(Tracker, "dameUltimaUbicacionConocida", UUC)
|
|
||||||
'Si ya pasaron mas de 15 minutos (900 segs) desde la ultima actualización, entonces mandamos UUC.
|
'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 ((DateTime.now - lastLocUpdate)/1000) > (interval * 1.5) Then
|
||||||
LogColor($"Mandamos ubicacion porque no se ha enviado en ${(interval * 1.5)} segs."$, Colors.red)
|
LogColor($"Mandamos "Ultima Ubicacion Conocida" porque no se ha enviado en ${(interval * 1.5)} segs."$, Colors.red)
|
||||||
Subs.mandaLocAServer(Tracker.FLP.GetLastKnownLocation, devModel)
|
CallSub2(Tracker, "dameUltimaUbicacionConocida", UUC)
|
||||||
|
If Tracker.FLP.IsInitialized Then Subs.mandaLocAServer(Tracker.FLP.GetLastKnownLocation, devModel)
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|||||||
4
Subs.bas
4
Subs.bas
@@ -169,7 +169,7 @@ End Sub
|
|||||||
|
|
||||||
Sub mandaLocAServer(loc As Location, id As String)
|
Sub mandaLocAServer(loc As Location, id As String)
|
||||||
Starter.lastLocUpdate = DateTime.Now
|
Starter.lastLocUpdate = DateTime.Now
|
||||||
CallSubDelayed(Main, "actualizaLabelUU")
|
If Not(IsPaused(Main)) Then CallSubDelayed(Main, "actualizaLabelUU")
|
||||||
Starter.cmd.Initialize
|
Starter.cmd.Initialize
|
||||||
Starter.cmd.Name = "guardaDatos"
|
Starter.cmd.Name = "guardaDatos"
|
||||||
Starter.cmd.Parameters = Array As Object(fechaKMT(DateTime.Now), id, fechaKMT(DateTime.Now), $"${loc.Latitude},${loc.Longitude},${loc.Accuracy},${loc.AccuracyValid},${loc.Speed},${loc.SpeedValid}"$, "Coords")
|
Starter.cmd.Parameters = Array As Object(fechaKMT(DateTime.Now), id, fechaKMT(DateTime.Now), $"${loc.Latitude},${loc.Longitude},${loc.Accuracy},${loc.AccuracyValid},${loc.Speed},${loc.SpeedValid}"$, "Coords")
|
||||||
@@ -179,7 +179,7 @@ Sub mandaLocAServer(loc As Location, id As String)
|
|||||||
Starter.reqManager.ExecuteCommand(Starter.cmd,"guardaDatos")
|
Starter.reqManager.ExecuteCommand(Starter.cmd,"guardaDatos")
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub ConvertMillisecondsToString(t As Long) As String
|
Sub ConvertMillisecondsToString(t As Long) As String 'ignore
|
||||||
Dim hours, minutes, seconds As Int
|
Dim hours, minutes, seconds As Int
|
||||||
hours = t / DateTime.TicksPerHour
|
hours = t / DateTime.TicksPerHour
|
||||||
minutes = (t Mod DateTime.TicksPerHour) / DateTime.TicksPerMinute
|
minutes = (t Mod DateTime.TicksPerHour) / DateTime.TicksPerMinute
|
||||||
|
|||||||
14
Tracker.bas
14
Tracker.bas
@@ -39,7 +39,7 @@ Sub Process_Globals
|
|||||||
'Para FusedLocationProvider (2 lineas)
|
'Para FusedLocationProvider (2 lineas)
|
||||||
Public FLP As FusedLocationProvider
|
Public FLP As FusedLocationProvider
|
||||||
Private flpStarted As Boolean
|
Private flpStarted As Boolean
|
||||||
Dim minAccuracy As Int = 50
|
Dim minAccuracy As Int = 30
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub Service_Create
|
Sub Service_Create
|
||||||
@@ -58,7 +58,7 @@ Sub flp_ConnectionSuccess
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub flp_ConnectionFailed(ConnectionResult1 As Int)
|
Sub flp_ConnectionFailed(ConnectionResult1 As Int)
|
||||||
if starter.logger then Log("Failed to connect to location provider")
|
If Starter.logger Then Log("Failed to connect to location provider")
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub Service_Start (StartingIntent As Intent)
|
Sub Service_Start (StartingIntent As Intent)
|
||||||
@@ -88,14 +88,15 @@ Public Sub StartFLP
|
|||||||
Loop
|
Loop
|
||||||
' If flpStarted = False Then
|
' If flpStarted = False Then
|
||||||
Log("RequestLocationUpdates")
|
Log("RequestLocationUpdates")
|
||||||
|
Starter.FLPStatus = "Searching" : LogColor("FLP Searching", Colors.blue)
|
||||||
FLP.RequestLocationUpdates(CreateLocationRequest) 'Buscamos ubicacion
|
FLP.RequestLocationUpdates(CreateLocationRequest) 'Buscamos ubicacion
|
||||||
Log("Buscamos ubicacion")
|
|
||||||
flpStarted = True
|
flpStarted = True
|
||||||
' End If
|
' End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub CreateLocationRequest As LocationRequest
|
Private Sub CreateLocationRequest As LocationRequest
|
||||||
' Log("CreateLocationRequest")
|
' Log("CreateLocationRequest")
|
||||||
|
Starter.FLPStatus = "Searching" : LogColor("FLP Searching", Colors.blue)
|
||||||
Dim lr As LocationRequest
|
Dim lr As LocationRequest
|
||||||
lr.Initialize
|
lr.Initialize
|
||||||
lr.SetInterval(30000) 'Intervalo deseado para actualizaciones de ubicacion en milisegundos
|
lr.SetInterval(30000) 'Intervalo deseado para actualizaciones de ubicacion en milisegundos
|
||||||
@@ -111,7 +112,7 @@ Sub dameUltimaUbicacionConocida(lastLocation As Location)
|
|||||||
If Starter.logger Then Log("This accuracy: " & FLP.GetLastKnownLocation.Accuracy)
|
If Starter.logger Then Log("This accuracy: " & FLP.GetLastKnownLocation.Accuracy)
|
||||||
If Starter.logger Then Log("This distance to previous: " & FLP.GetLastKnownLocation.DistanceTo(lastLocation))
|
If Starter.logger Then Log("This distance to previous: " & FLP.GetLastKnownLocation.DistanceTo(lastLocation))
|
||||||
Dim coords As String = FLP.GetLastKnownLocation.Latitude&","&FLP.GetLastKnownLocation.Longitude&","&Subs.formatoFecha(FLP.GetLastKnownLocation.Time)
|
Dim coords As String = FLP.GetLastKnownLocation.Latitude&","&FLP.GetLastKnownLocation.Longitude&","&Subs.formatoFecha(FLP.GetLastKnownLocation.Time)
|
||||||
If FLP.GetLastKnownLocation.Accuracy < 30 And FLP.GetLastKnownLocation.DistanceTo(lastLocation) > 25 Then
|
If FLP.GetLastKnownLocation.Accuracy < minAccuracy And FLP.GetLastKnownLocation.DistanceTo(lastLocation) > 25 Then
|
||||||
Starter.UUC = FLP.GetLastKnownLocation
|
Starter.UUC = FLP.GetLastKnownLocation
|
||||||
Subs.mandaLocAServer(FLP.GetLastKnownLocation, Starter.devModel)
|
Subs.mandaLocAServer(FLP.GetLastKnownLocation, Starter.devModel)
|
||||||
If Starter.logger Then Log("Mandamos GetLastKnownLocation : "&DateTime.Time(FLP.GetLastKnownLocation.Time))
|
If Starter.logger Then Log("Mandamos GetLastKnownLocation : "&DateTime.Time(FLP.GetLastKnownLocation.Time))
|
||||||
@@ -133,7 +134,8 @@ Public Sub StopFLP
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub flp_LocationChanged (Location1 As Location)
|
Sub flp_LocationChanged (Location1 As Location)
|
||||||
If Not(Starter.Timer1.Enabled) Then Starter.Timer1.Enabled = True : Log("timer enabled")
|
Starter.FLPStatus = "Location changed" : LogColor("Location changed", Colors.blue)
|
||||||
|
If Not(Starter.Timer1.Enabled) Then Starter.Timer1.Enabled = True : Log("timer enabled")
|
||||||
If Starter.logger Then LogColor("FLP_LocationChanged", Colors.Red)
|
If Starter.logger Then LogColor("FLP_LocationChanged", Colors.Red)
|
||||||
' ToastMessageShow("FLP_LocationChanged", False)
|
' ToastMessageShow("FLP_LocationChanged", False)
|
||||||
Dim coords As String = Location1.Latitude&","&Location1.Longitude&","&Subs.formatoFecha(DateTime.Now)
|
Dim coords As String = Location1.Latitude&","&Location1.Longitude&","&Subs.formatoFecha(DateTime.Now)
|
||||||
@@ -147,7 +149,7 @@ Sub flp_LocationChanged (Location1 As Location)
|
|||||||
If Location1.Accuracy < minAccuracy Then CallSubDelayed2(FirebaseMessaging,"mandamosLoc",coords)
|
If Location1.Accuracy < minAccuracy Then CallSubDelayed2(FirebaseMessaging,"mandamosLoc",coords)
|
||||||
If Location1.Accuracy < minAccuracy Then Starter.UUC = Location1
|
If Location1.Accuracy < minAccuracy Then Starter.UUC = Location1
|
||||||
If Location1.Accuracy < minAccuracy Then Subs.mandaLocAServer(Location1, Starter.devModel)
|
If Location1.Accuracy < minAccuracy Then Subs.mandaLocAServer(Location1, Starter.devModel)
|
||||||
if starter.logger then Log("Loc changed : "&Location1.Latitude&","&Location1.Longitude&"|"&Starter.devModel&"|")
|
If Starter.logger Then Log("Loc changed : "&Location1.Latitude&","&Location1.Longitude&"|"&Starter.devModel&"|")
|
||||||
CallSubDelayed(Main, "ponCoords")
|
CallSubDelayed(Main, "ponCoords")
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user