SignalK / signalk-java

Installer and web-app for the artemis-server (a java based Signal K master server)
Apache License 2.0
6 stars 6 forks source link

Subscriptions #27

Open bdbcat opened 4 years ago

bdbcat commented 4 years ago

Rob42...

I am the Lead Dev for OpenCPN. As an experiment, I am adapting OCPN for basic SK/JSON message processing, planning to use direct TCP connection to a signalk-java server accessible to the system.

I am using a serial port NMEA input connection to the server, which is monitored and reported correctly by the REST API, available on the server management interface.

From my OCPN client I create a TCP socket to the remote server at port 55555 (the default). The socket connects OK, and I get a nice "welcome" response from the server. I then attempt to subscribe to some data by simply sending the following JSON message down the socket:

c++ code: char sub2[] = "{\"context\":\"vessels.\",\"subscribe\":[{\"path\":\"navigation.course\"}]}"; GetSock()->Write(sub2, strlen(sub2));

No error on the write. But nothing ever comes back from the server.

What am I missing? Thanks Dave

rob42 commented 4 years ago

You may need an * eg (pretty print for clarity, send as single line) `{ "context": "vessels.", <<< HERE "subscribe": [ { "path": "navigation" <<< Also try a wider path. You may not have any 'course' data } ] }


Check you are actually sending, and you may need to end the message with [CR/LF] which marks end of message over tcp.
tkurki commented 4 years ago

The specification talks explicitly about using wildcards, so I believe the subcription for all values with prefix navigation should be "path": "navigation.*".

I think it is high time we revisit the Signal K over tcp / bytestream and specify the message delimiter.

bdbcat commented 4 years ago

rob42... Working now. The "missing *" characters were actually in my code, just fell out of the cut/paste. The key was missing delimiter. I found that "\n" worked OK. Could not find any reference to delimiters in sk specification. Thanks Dave

bdbcat commented 4 years ago

Correction to above. Required message delimiter is "\r\n", or CR\LF. Dave