I have custom GPS tracker. It periodically send data to server via GSM. (for example twice/hour)
There is a situation when GSM signal may be lost and device can't sent data to sever in correct time. In this situation server must send notification to email or SMS.
I use OpenGTS.
Any idea how to implement this?
You can use Cron Job and Simple Unix Script. ( Only if u have shell access and using Linux OS)
Scan all the devices from Device Table and check the last data received time.
Thank for idea. But I use Windows as server.
I add some function to tk10x code.
and add two field to Device.java
public static final String FLD_deviceLostSignal = "DeviceLostSignal"; //DeviceLostSignal
public static final String FLD_notificationFlag = "NotificationFlag";
new DBField(FLD_deviceLostSignal , Boolean.TYPE , DBField.TYPE_BOOLEAN , I18N.getString(Device.class,"Device.fld.deviceLostSignal" , "DeviceLostSignal" ), "edit=2"),
new DBField(FLD_notificationFlag , Boolean.TYPE , DBField.TYPE_BOOLEAN , I18N.getString(Device.class,"Device.fld.notificationFlag" , "NotificationFlag" ), "edit=2"),
and get/set function http://pastebin.com/hw2q2J2f
This is my test log
Thus must be set device.setDeviceLostSignal(true); device.setNotificationFlag(false);
But when I see a database via SQLyog I see DeviceLostSignal == 0 and NotificationFlag ==0.
Where is my problem?
In Device.sql Table there are 2 field. LAST latitude and longitude with time.
So just use while loop in java program and check the last data received on server and If any value is matching with your requirement then send an email.
Use schedule task to run the script or alternate way is make a bin file and start that file on boot up and add sleep timer in it.
I am trying to understand why my function (http://pastebin.com/F9LBPDjH) not update fields in DB.