Hi,
I am sending some data from routeros to a dashboarding application called Thingsboard via http/curl.
I recently upgraded to routeros v6.44 and I read in the forums that I need to change the fetch command from “http-content-type” to http-header-field=“Content-Type: xxx”.
I have done this and it works for one of my scripts. However, it does not work for the script that sends the GPS position information. In this case, the script appears to run OK as the GPS data appears in the CLI in the correct format, but does not update the Thingsboard application. Nothing has changed in Thingsboard, the only change is the routeros upgrade and the above syntax. Here is the script:
{
:global lat
:global lon
/system gps monitor once do={
:set $lat $(“latitude”)
:set $lon $(“longitude”)
};
:tool fetch mode=http url=“http://10.0.1.186/api/v1/<>/telemetry” port=9090 http-method=post
http-data=(“{"latitude":"” . $lat . “","longitude":"” . $lon . “"}”) http-header-field=“Content-Type:application/json”
:put (“{"latitude":"” . $lat . “","longitude":"” . $lon . “"}”)
};
This results in an output as follows when run in CLI:
[admin@gsm_bl02a] > system script run tracker
date-and-time: apr/17/2019 08:32:23
latitude: N 55 58’ 9.78’’
longitude: W 3 9’ 53.10’’
altitude: 22.500000m
speed: 2.759480 km/h
destination-bearing: none
true-bearing: 19.850000 deg. True
magnetic-bearing: none
valid: yes
satellites: 6
fix-quality: 1
horizontal-dilution: 1.7
status: finished
downloaded: 0KiBC-z pause]
duration: 1s
{“latitude”:“N 55 58’ 9.78’'”,“longitude”:“W 3 9’ 53.10’'”}To me, this looks correct, but whereas previously the latest telemetry would appear in the device information in Thingsboard, after the upgrade to 6.44 this no longer happens (nothing is received from this particular script though another script on the same board sending LTE signal information works OK). GPS info is in the same format it was previously (DMS).
Update: If the GPS signal is absent, the script successfully posts the word “none” in the values for latitude and longitude. When the GPS signal becomes valid, nothing is posted, even though the correct lat/long values are printed in the terminal.