GPS Tracker (TK102) flow

#1

I have a GPRS based GPS tracker, which can talk to a custom server using tcp/udp.
In php I can get this thing to talk properly, but in Node Red I have some issues.

It uses a specific protocol, it sends "logon requests" which look like:

##,imei:864180031021079,A;
To which I have to answer:
LOAD

I receive the first string and answer with LOAD, but don't get any response, and the first string is received again (meaning it ignored the LOAD).

I suspect that there is a carriage return character missing, but I have tried sending those as well, no result.

In php I send @socket_send($socket, "LOAD", 4, 0);
Is this comparable in Node Red when I send a string to the TCP-Out node ?

Debug:

Received

{
  "topic": "",
  "payload": "##,imei:864180031021079,A;",
  "ip": "::ffff:188.91.5.163",
  "port": 50079,
  "_session": {
    "type": "tcp",
    "id": "f51d00d1.bc868"
  },
  "_msgid": "9406bca6.3ab38"
}

Send:

{
  "payload": "LOAD",
  "_session": {
    "type": "tcp",
    "id": "f51d00d1.bc868"
  },
  "_msgid": "9406bca6.3ab38"
}

No response.

My flow

[{"id":"3942e3dc.4acb8c","type":"tcp in","z":"91379f0e.71d7b","name":"GPS","server":"server","host":"","port":"16000","datamode":"single","datatype":"utf8","newline":"","topic":"","base64":false,"x":110,"y":200,"wires":[["2345024b.004256","5caf7ab2.83cf9c"]]},{"id":"2345024b.004256","type":"function","z":"91379f0e.71d7b","name":"","func":"\nm = msg.payload\n\nif(m == \"##,imei:864180031021079,A;\" ){\n    return {\"payload\":\"LOAD\",\"_session\":msg._session}    \n    }\nelse if(m == \"864180031021079\" ) {\n    return {\"payload\":\"ON\",\"_session\":msg._session}    \n}","outputs":1,"noerr":0,"x":250,"y":200,"wires":[["23939e1f.c6248a"]]},{"id":"dbaf86a8.0990b8","type":"tcp out","z":"91379f0e.71d7b","host":"","port":"","beserver":"reply","base64":true,"end":false,"name":"","x":590,"y":200,"wires":[]},{"id":"df71b0b5.69a688","type":"debug","z":"91379f0e.71d7b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":590,"y":260,"wires":[]},{"id":"5caf7ab2.83cf9c","type":"debug","z":"91379f0e.71d7b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":230,"y":300,"wires":[]},{"id":"23939e1f.c6248a","type":"delay","z":"91379f0e.71d7b","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":400,"y":200,"wires":[["dbaf86a8.0990b8","df71b0b5.69a688"]]}]

Note the "decode base64" checkbox should be turned off, but no difference.

Will "ip": "::ffff:188.91.5.163" send it to the correct IP ?

0 Likes

#2

Found it.

Should have used a "stream of string" instead.

0 Likes