Creating a TCP connection to the Cloud Stream CoAp?

Hopefully this is a very basic question. I have a working labview program to talk to my proton, works very nice all through HTTPS native commands (thanks Fred).

Now I want to receive events from the stream. I have done this via curl embedded in my labview code,

but it seems clunky to me, so I want to try a TCP connection and then listen to the open port. From what i understand i need to open a TCP connection to particle’s multicast server and then listen for data. is that right, or am i lost?

What i want to emulate is the command line command of “particle subscribe mine”

i have tried the following but i just get malformed address responses when i try to open the connection

address: 224.0.1.187
port: 5683

and

address: tcp://device.spark.io
port: 5683

Labview is pretty basic so I am not sure what i doing wrong

am i just missing something basic, or is this not the way to do this?

You should look into EventStreams. It is HTTP but you can filter to just your stream, certain events in your stream, all your devices etc. I’m not familiar with lab view but a simple node.js service can do this.

https://docs.particle.io/reference/api/#get-a-stream-of-events

well, i took the easier route of just having labview launch a powershell with “particle subscribe mine” redirected to a file. I then display and parse the file. Labview’s native HTTP commands seem to hate anything that waits too long, and basically the SSE waits until you stop it. And I am not good enough to open and handshake a TCP connection to the stream just yet.

I could have just as easily run the shell with “curl https://api.particle.io/v1/devices/events/temp?access_token=1234”.

I am sure it can be done by someone, but my way works, and I even get a log file of the event stream as a bonus!

thanks

Well you can’t use TCP with Event Streams since they are Server Sent Events in all actuality. That is an HTTP spec so raw TCP won’t work for anyone. http://www.w3schools.com/html/html5_serversentevents.asp

If you just want to pipe an event stream to a file, then curl is your best option:

curl --no-buffer https://api.spark.io/v1/events/mySpecialEventName/?access_token=99...11 > myFile.txt