HowTo use REST/JSON
REST specific PFAL commands
-
command to sent HTTP REST with URL encodiong TCP.Send.Rest,"",,""
- : http:// must be included!; optional :<port_number> is possible
- : 0 - no encryption is used
- : url-encoded key1=val1&key2=val2&..&key=val
-
command to sent HTTP REST with JSON body
TCP.Send.JSON,"<URL>",<enableBodyEncryption>,"<Parameter-String>"
- : http:// must be included!; optional :<port_number> is possible
- : 0 - no encryption is used
- : have to start with { and end with } key names have to enclosed by escaped character ' between key and value the character : is required values: strings have to enclosed by escaped character ' fractional numbers with . as separator
-
new dynamic entry &(HttpResponse) - reports the last responded HTTP status message/error code
-
write command for Multi parameter JSON
TCP.JSON.Write,"<Parameter-String>"
write single data line to flash buffer for unsent msg, each with leading marker
- flush command for Multi parameter JSON
TCP.JSON.Flush,"<URL>",<enableBodyEncryption>,"<Parameter-String>"
send unsent data as MultiMsg JSON : JSON with additional marker as placeholder for stored single data lines {,}
EXAMPLE
simple send position data
PFAL command example
PFAL command example to write JSON data (executed multiple times)
$PFAL,TCP.JSON.Write,"{
<d4fb>\'&(Date)_&(Time)\':{\'IMEI\':&(IMEI),\'AI1\':&(IN1)}}"
PFAL command example to flush
$PFAL,TCP.JSON.Flush,"http://59.181.166.3:47000/demo/telematics",0,"{\'KEY\':\'&(Date)_&(Time)\',\'MOVELETKEY\':\'blackbox-fox3\',\'ACK\':\'SUCCESS\',\'PARTICIPANTKEY\':\'&(Date)_&(Time)\',<d4fb>}"
HTTP POST
POST /demo/telematics HTTP/1.0
HOST: 59.181.166.3..User-Agent:AVLemb/2.13
Content-Type: application/json; charset=ISO-8859-1
FAL-IMEI: 353816054730215..FAL-ENCRYPTION: 1
Content-Length: 776
{"KEY":"06.01.1980_00:09:21","MOVELETKEY":"blackbox-fox3","ACK":"SUCCESS","PARTICIPANTKEY"
:"06.01.1980_00:09:21",
"06.01.1980_00:01:00":{"LAT":0.0000000,"LON":0.0000000,"IMEI":353816054730215},
"06.01.1980_00:01:01":{"LAT":0.0000000,"LON":0.0000000,"IMEI":353816054730215},
"06.01.1980_00:01:38":{"LAT":0.0000000,"LON":0.0000000,"IMEI":353816054730215},
"06.01.1980_00:02:56":{"LAT":0.0000000,"LON":0.0000000,"IMEI":353816054730215},
"06.01.1980_00:03:15":{"LAT":0.0000000,"LON":0.0000000,"IMEI":353816054730215},
"06.01.1980_00:03:26":{"LAT":0.0000000,"LON":0.0000000,"IMEI":353816054730215},
"06.01.1980_00:04:09":{"LAT":0.0000000,"LON":0.0000000,"IMEI":353816054730215}
}