# GPS Tracker (TK102) flow

**URL:** <https://discourse.nodered.org/t/gps-tracker-tk102-flow/8776>\
**Category:** General\
**Created:** [9 March 2019 13:48 UTC](https://discourse.nodered.org/t/gps-tracker-tk102-flow/8776 "2019-03-09T13:48:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [9 March 2019 13:48 UTC](https://discourse.nodered.org/t/gps-tracker-tk102-flow/8776/1 "2019-03-09T13:48:13Z")

</div>

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

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

```

Send:

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

```

No response.

My flow

```auto
[{"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 ?

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [9 March 2019 14:18 UTC](https://discourse.nodered.org/t/gps-tracker-tk102-flow/8776/2 "2019-03-09T14:18:02Z")

</div>

Found it.

Should have used a "stream of string" instead.

---

<div class="post-metadata">

**Author:** ![liebefuroscar](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/liebefuroscar/32/49404_2.png) [@liebefuroscar](https://discourse.nodered.org/u/liebefuroscar)\
**Post date:** [14 October 2021 15:27 UTC](https://discourse.nodered.org/t/gps-tracker-tk102-flow/8776/3 "2021-10-14T15:27:15Z")

</div>

Im trying to integrate in Nodered. Can u please share ur working flow?

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [15 October 2021 05:37 UTC](https://discourse.nodered.org/t/gps-tracker-tk102-flow/8776/4 "2021-10-15T05:37:52Z")

</div>

I no longer use that flow (GPS tracker worked on 2G, no longer available here).

But I think you can import the flow I posted and change the "GPS" node and set the output to stream of string.
