Writing scripts for Teltonika routers is easy. You can learn basic commands/functions in no time.
I have wrote basic script for you. Feel free to edit the script to your needs (e.g. rearrange/change information which should be save, etc). In script information is saved with "tab" spacing in between values, which means, that you can open the output text file with e.g. Notepad++ application and then copy->paste everything to e.g. excel worksheet and have a nice table. Here is the script:
#Specify location path and name of the file and frequency how often data should be written to the file
if [ ! -f $FILE ]; then # Checks if file exists. If not, creates it
echo -e 'Latitude \tLongitude \tDatetime \tAltitude \tSpeed \tCourse over ground' > $FILE
while [ 1 ]; do # Infinite while loop
if [ $(gpsctl -s) -eq 1 ]; then # Checks for GPS fix
echo -e $(gpsctl -i) '\t' $(gpsctl -x) '\t' $(gpsctl -e) '\t' $(gpsctl -a) '\t' $(gpsctl -v) '\t' $(gpsctl -c) >> $FILE
In the top of the script your have to specify the file path/file name and the frequency in seconds how often data should be collected. To find out what file path to use, connect your external storage (USB or uSD card) and navigate to router's "Services -> USB Tools" menu. In "Mount Point" column you will see path location for your storage:
Once you have specified your storage's file path, file name and desired data collection frequency, connect to router via SSH (e.g. using Putty application):
- SSH login: root
- SSH password: <your router's password>
and do the following:
- Type "vi /bin/script.sh" (feel free to change the name of the script)
- Press "a" keyboard button.
- Paste the script here (if you are using Putty application, that can be done with right mouse click)
- Press "esc" keyboard button and type ":x"
- Type "chmod +x /bin/script.sh" (if you have chosen different script name do not forget to use same name here and in step 6)
- Connect to router's WebUI, navigate to "System -> User scripts" menu and type "/bin/script.sh" above existing "exit 0" line.
- Restart the router.
Once your router is restarted, it should create new file in your external storage. Once router will get "GPS fix" (i.e. find out it's GPS location) it should start storing GPS information in this file.
Let me know if you have managed to successfully run the script and that this is indeed what you were looking for.