Beantwoord

Node-Red TCP/IP Server

  • 11 september 2020
  • 2 reacties
  • 78 keer bekeken

Hi,

Het is gelukt om door middel van een BG96 en het dragino LTE-M shield te communiceren met een TCP/IP ECHO server van http://www.noomio.com.au/wiki/bg96/tcp-connection-with-at-commands-and-bg96/ 

 

Maar nu wil ik zelf een TCP/IP server opzetten om naar te communiceren. Ik kreeg de tip bij m'n vorige forum vraag om Node-Red te gebruiken, Node-Red heb ik geïnstalleerd en dat draait nu op m'n Windows 10 PC. Nu is het probleem dat een TCP/IP server erin krijgen niet lukt, kunnen jullie mij helpen? ik heb al wel de TCP plugin gedownload en geïnstalleerd.

Alvast bedankt!

Met vriendelijke groet,

Daniel Spils

icon

Beste antwoord door maarten bartels 11 september 2020, 12:20

Hallo Daniel,

 

Hieronder staat een stukje voorbeeld flow, dat je kan importeren in NodeRed. Deze flow luistert op TCP port 3000 en geeft een vast antwoord. Let op dat de server wel echt bereikbaar is voor je device op deze port (firewall rules etc.).

 

[{"id":"c699bfa8.6dba3","type":"tcp in","z":"e2565594.1da088","name":"get TCP data from 3000","server":"server","host":"","port":"3000","datamode":"stream","datatype":"buffer","newline":"","topic":"","base64":false,"x":260,"y":1180,"wires":[["104f68ff.d51c07"]]},{"id":"e16dd5af.7adb58","type":"tcp out","z":"e2565594.1da088","host":"","port":"","beserver":"reply","base64":false,"end":false,"name":"","x":730,"y":1180,"wires":[]},{"id":"104f68ff.d51c07","type":"function","z":"e2565594.1da088","name":"set TCP destination","func":"srcip = msg.ip;\nsrcport = msg.port;\ntext = \"ACK1:\" + msg.payload;\n\nmsg = { ip: srcip, port: srcport, payload: text }\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":1180,"wires":[["e16dd5af.7adb58"]]}]

 

Ik heb deze flow zelf getest met onderstaande AT commando's:

 

[2020-09-11 12:14:19:700_S:] at+qiact?
[2020-09-11 12:14:19:705_R:] at+qiact?
[2020-09-11 12:14:19:712_R:] +QIACT: 1,1,1,"62.133.89.8"

[2020-09-11 12:14:19:712_R:] OK
[2020-09-11 12:14:34:571_S:] AT+QIOPEN=1,1,"TCP","a.b.c.d",3000
[2020-09-11 12:14:34:579_R:] AT+QIOPEN=1,1,"TCP","a.b.c.d",3000
[2020-09-11 12:14:34:579_R:] OK

[2020-09-11 12:14:34:653_R:] +QIOPEN: 1,0

[2020-09-11 12:14:34:657_R:] DSR:0 CTS:0 (RI:1) DCD:0

[2020-09-11 12:14:34:775_R:] DSR:0 CTS:0 (RI:0) DCD:0
[2020-09-11 12:14:47:691_S:] AT+QISEND=1,3
[2020-09-11 12:14:47:698_R:] AT+QISEND=1,3
[2020-09-11 12:14:47:698_R:] > HOI
[2020-09-11 12:14:53:049_R:] HOI
[2020-09-11 12:14:53:049_R:] SEND OK

[2020-09-11 12:14:53:117_R:] +QIURC: "recv",1
[2020-09-11 12:14:53:120_S:] AT+QIRD=1

[2020-09-11 12:14:53:124_R:] DSR:0 CTS:0 (RI:1) DCD:0
[2020-09-11 12:14:53:132_R:] AT+QIRD=1
[2020-09-11 12:14:53:132_R:] +QIRD: 8
[2020-09-11 12:14:53:132_R:] ACK1:HOI

[2020-09-11 12:14:53:132_R:] OK

[2020-09-11 12:14:53:239_R:] DSR:0 CTS:0 (RI:0) DCD:0
[2020-09-11 12:15:00:619_S:] AT+QICLOSE=1
[2020-09-11 12:15:00:625_R:] AT+QICLOSE=1
[2020-09-11 12:15:10:626_R:] OK
 

Succes!

 

Maarten

 

Bekijk origineel

2 reacties

Hallo Daniel,

 

Hieronder staat een stukje voorbeeld flow, dat je kan importeren in NodeRed. Deze flow luistert op TCP port 3000 en geeft een vast antwoord. Let op dat de server wel echt bereikbaar is voor je device op deze port (firewall rules etc.).

 

[{"id":"c699bfa8.6dba3","type":"tcp in","z":"e2565594.1da088","name":"get TCP data from 3000","server":"server","host":"","port":"3000","datamode":"stream","datatype":"buffer","newline":"","topic":"","base64":false,"x":260,"y":1180,"wires":[["104f68ff.d51c07"]]},{"id":"e16dd5af.7adb58","type":"tcp out","z":"e2565594.1da088","host":"","port":"","beserver":"reply","base64":false,"end":false,"name":"","x":730,"y":1180,"wires":[]},{"id":"104f68ff.d51c07","type":"function","z":"e2565594.1da088","name":"set TCP destination","func":"srcip = msg.ip;\nsrcport = msg.port;\ntext = \"ACK1:\" + msg.payload;\n\nmsg = { ip: srcip, port: srcport, payload: text }\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":1180,"wires":[["e16dd5af.7adb58"]]}]

 

Ik heb deze flow zelf getest met onderstaande AT commando's:

 

[2020-09-11 12:14:19:700_S:] at+qiact?
[2020-09-11 12:14:19:705_R:] at+qiact?
[2020-09-11 12:14:19:712_R:] +QIACT: 1,1,1,"62.133.89.8"

[2020-09-11 12:14:19:712_R:] OK
[2020-09-11 12:14:34:571_S:] AT+QIOPEN=1,1,"TCP","a.b.c.d",3000
[2020-09-11 12:14:34:579_R:] AT+QIOPEN=1,1,"TCP","a.b.c.d",3000
[2020-09-11 12:14:34:579_R:] OK

[2020-09-11 12:14:34:653_R:] +QIOPEN: 1,0

[2020-09-11 12:14:34:657_R:] DSR:0 CTS:0 (RI:1) DCD:0

[2020-09-11 12:14:34:775_R:] DSR:0 CTS:0 (RI:0) DCD:0
[2020-09-11 12:14:47:691_S:] AT+QISEND=1,3
[2020-09-11 12:14:47:698_R:] AT+QISEND=1,3
[2020-09-11 12:14:47:698_R:] > HOI
[2020-09-11 12:14:53:049_R:] HOI
[2020-09-11 12:14:53:049_R:] SEND OK

[2020-09-11 12:14:53:117_R:] +QIURC: "recv",1
[2020-09-11 12:14:53:120_S:] AT+QIRD=1

[2020-09-11 12:14:53:124_R:] DSR:0 CTS:0 (RI:1) DCD:0
[2020-09-11 12:14:53:132_R:] AT+QIRD=1
[2020-09-11 12:14:53:132_R:] +QIRD: 8
[2020-09-11 12:14:53:132_R:] ACK1:HOI

[2020-09-11 12:14:53:132_R:] OK

[2020-09-11 12:14:53:239_R:] DSR:0 CTS:0 (RI:0) DCD:0
[2020-09-11 12:15:00:619_S:] AT+QICLOSE=1
[2020-09-11 12:15:00:625_R:] AT+QICLOSE=1
[2020-09-11 12:15:10:626_R:] OK
 

Succes!

 

Maarten

 

Beste Maarten,

Wederom bedankt!

Reageer