- Log into the mikrotik router and go to New Terminal
- Paste the following code into the terminal:
/sys gps set enabled=yes port=usb3 channel=1 init-string="\$GPS_START"
- Go to System->Scripts
- Add a new script and name it "GPS"
- Paste the following script into the window:
:local ffnumber 6 :local voltage [/system health get voltage] :local cameraserial [/ip dhcp-server lease get [find comment=Camera] host-name] # Get GPS info and find variables :system gps monitor file="gps.txt"; :global gpstext [/file get gps.txt contents]; :local datestart [:find $gpstext "time: "]; :local dateend [:find $gpstext "latitude"]; :local date [:pick $gpstext ($datestart +6) ($dateend -14)] :local longstart [:find $gpstext "longitude" -1]; :local longend [:find $gpstext "\n" $longstart]; :local latstart [:find $gpstext "latitude" -1]; :local latend [:find $gpstext "\n" $latstart]; :local validstart [:find $gpstext "valid" -1]; :local validend [:find $gpstext "\n" $validstart]; :local speedstart [:find $gpstext "speed"]; :local speedend [:find $gpstext "." $speedstart]; :local speed [;pick $gpstext ($speedstart +7) ($speedend +3)]; :local altitudestart [:find $gpstext "altitude"]; :local altitudeend [:find $gpstext "." $altitudestart]; :local altitude [;pick $gpstext ($altitudestart +10) ($altitudeend +3)]; :local satellitesstart [:find $gpstext "satellites"]; :local satellitesend [:find $gpstext "\n" $satellitesstart]; :local satellites [;pick $gpstext ($satellitesstart +12) ($satellitesend)]; :local valid false; :local zeros ""; :local technology; :if ($techno ="GSM compact") do={[:set technology "GSM";]} :if ($techno ="3G") do={:set technology "UMTS";} :if ($techno ="Evolved 3G (LTE)") do={[:set technology "LTE";]} :if ([:find $gpstext "yes" $validstart] > 0) do={:set valid true;}; :global longitude [:pick $gpstext ($longstart + 11) $longend]; :local degreestart [:find $longitude " " -1]; :local minutestart [:find $longitude " " $degreestart]; :local secondstart [:find $longitude "'" $minutestart]; :local secondend; :local secfract; :if ([:len [:find $longitude "." 0]] < 1) do={ :set secondend [:find $longitude "'" $secondstart]; :set secfract "0"; } else={ :set secondend [:find $longitude "." $secondstart]; :set secfract [:pick $longitude ($secondend + 1) ($secondend + 2)]; }; :local longdegree; :local longdegreelink; :if ([:pick $longitude 0 1] = "W") do={ :set longdegree "-"; :set longdegreelink "W"; } else={ :set longdegree "+"; :set longdegreelink "E"; }; :set longdegree ($longdegree . [:pick $longitude 2 $minutestart]); :set longdegreelink ($longdegreelink . [:pick $longitude 2 $minutestart]); :local longmin [:pick $longitude ($minutestart + 1) $secondstart]; :local longsec [:pick $longitude ($secondstart + 2) $secondend]; :local longfract ((([:tonum $longmin] * 6000) + ([:tonum $longsec] * 100) + ([:tonum $secfract] * 10) ) / 36); :while (([:len $zeros] + [:len $longfract]) < 4) do={ :set zeros ($zeros . "0"); }; :global newlong ($longdegree . "." . $zeros . $longfract); :global newlonglink ($longdegreelink . "." . $zeros . $longfract); :global latitude [:pick $gpstext (latstart + 10) $latend]; :set degreestart [:find $latitude " " -1]; :set minutestart [:find $latitude " " $degreestart]; :set secondstart [:find $latitude "'" $minutestart]; :if ([:len [:find $latitude "." 0]] < 1) do={ :set secondend [:find $latitude "'" $secondstart]; :set secfract "0"; } else={ :set secondend [:find $latitude "." $secondstart]; :set secfract [:pick $latitude ($secondend + 1) ($secondend +2)]; }; :local latdegree; :local latdegreelink; :if ([:pick $latitude 0 1] = "N") do={ :set latdegree "+"; :set latdegreelink "N"; } else={ :set latdegree "-"; :set latdegreelink "S"; }; :set latdegree ($latdegree . [:pick $latitude 2 $minutestart]); :set latdegreelink ($latdegreelink . [:pick $latitude 2 $minutestart]); :local latmin [:pick $latitude ($minutestart + 1) $secondstart]; :local latsec [:pick $latitude ($secondstart + 2) $secondend]; :local latfract ((([:tonum $latmin] * 6000) + ([:tonum $latsec] * 100) +([:tonum $secfract] * 10)) / 36); :set zeros ""; :while (([:len $zeros] + [:len $latfract]) < 4) do={ :set zeros ($zeros . "0"); }; :global newlat ($latdegree . "." . $zeros . $latfract); :global newlatlink ($latdegreelink . "." . $zeros . $latfract); :global coordinates ($newlong . "," . $newlat) :local url "https://www.aerialfireview.co.za/api/v1/firefly_gps/$ffnumber/$newlat/$newlong/$voltage/$altitude/$cameraserial" #:log warning $url /tool fetch url=$url :local url "https://www.firehawk.co.za/api/v1/firefly_gps/$ffnumber/$newlat/$newlong/$voltage/$altitude" /tool fetch url=$url #:log warning $url
- Change the id number to the firefly number
- Press Apply and then Ok
- Add a new script and name it "Image Upload"
- Paste the following script into the window:
local ip [/ip dhcp-server lease get [find comment=Camera] address] local user "admin"<span class="fr-marker" data-id="0" data-type="false" style="display: none; line-height: 0;"></span><span class="fr-marker" data-id="0" data-type="true" style="display: none; line-height: 0;"></span> local pass "admin" local ffnumber 6 /tool fetch user=$user password=$pass url="http://$ip/cgi-bin/snapshot.cgi" mode=http dst-path=image.jpg /tool fetch address=ftp.firehawk.co.za src-path=image.jpg user=willem password=qwer1234 dst-path="firefly_website/static/images/$ffnumber.jpg" mode=ftp upload=yes
- Change the firefly number to the correct values
- Press Apply and then Ok
Now go to System->Scheduler
Add a New Schedule and Name it "Firefly Online"
Make sure the interval is set to 00:00:05. Start Date can be set to any date prior to Today.
Add a New Schedule and Name it "Image Upload:
Paste the following code into the Scheduler:
/system script run "Image Upload"
- Make sure the interval is 00:00:15. Start Time should be set to startup startup. Start Date can be set to any date prior to Today.
Please make sure that your System->Clock is set correct
It is very important that the DHCP Lease for the Firefly Camera has a comment "Camera" this is case sensitive
Open up a new terminal
This window will open:
Type is the following:
/system script run GPS
If you get a response saying then everything is set up correctly. If not continue down this guide.
If you get this error then you will need to go to IP->DNS
Change the top sections to look like this and click Apply and OK.
Redo step 14 and you will get the correct response from the system.
Firefly Voltage Script v2 - GPS Print
Modified on: Wed, 29 May, 2019 at 1:16 PM
Did you find it helpful? Yes No
Send feedbackSorry we couldn't be helpful. Help us improve this article with your feedback.