Have you actually tried a forum search on “tcp”? There are quite a few topics about it… I can see four topics if I just glance at the forum.
So yeah, I’m pretty sure it’s possible.
Well, it’s actually impossible to do it via the TCPServer object (I am pretty sure). I haven’t seen anybody do this, and it is what I would like to do.
On the client side, I suppose I could hack something together where I request from a server whether they want me to do something… but that isn’t really what I want either.
Yes, I have looked – as far as I can tell, no one is controlling their spark through TCP (plenty are sending data from their spark to a server though)
Would you care to elaborate a bit further on what it is that you’re trying to accomplish? Maybe a small example so that we get a basic idea of the general concept. Let’s ping, I dunno, @bko for this one, he’s fairly knowledgable in all things Spark related.
I am not sure what you mean that TCPServer cannot provide a web control for the core–lots things do this already (without using the Spark cloud). The only thing the Spark core can’t really do is SSL/TLS HTTPS connections to secure web sites (like the Spark cloud) but if you have a server, you can just control the core with a HTTP page served by the core itself.
So I think a use-case describing what you want the user (or yourself) to do when they interact with the core and then what the core does in response is really the next step.
if(server.data_available()){ // data is available (a client made a POST request)
// Move data into a buffer
for(int n = 0; n<buf_len; n++){
buf[n] = server.read();
if(not server.data_available()) break;
}
// Process buffer and do whatever I want with it.
}
something like that. It is not supported by the TCP Server at the moment.
As of what I did, I actually implemented just one Spark.function. The rest are called within that function or dispatched from inside loop()
I took a slightly different approach, passing the whatever data (in this case, strings) as a POST/GET parameters to my Spark.function. I think having a TCPClient or TCPServer to read JSON is totally possible, just that you might need some parsing to do to read it back as usable JSON from buffer of characters or strings.