So, I’ve proven to myself that one can send raw TCP data with sendHubCommand(). Whatever data I pass to sendHubCommand() is delivered unmodified, which is as raw as it get. This is how my app talks to Mochad X10 gateway in this demo:
The question now is how to receive anything back. Currently, the hub sends back empty response, which is enough to confirm that data was sent successfully, but it would be much more useful if I could get data back from the socket.
I know that sendHubCommand() takes an undocumented options argument, so the question is if there’s a magic option that can make the hub send reply back to the app?
Which points correctly to my TCP gateway (192.168.1.139:1099). The hub waits about 3 - 4 seconds before closing the socket and sending response. If the socket is closed by the server, the hub sends response immediately. In either case, no response data shows up in the event.
The hub doesn’t actually interpret the data. All non-discovery LAN socket traffic goes up to the cloud where the cloud looks for a valid HTTP frame to pass a whole response up to the device type. This allows a developer to handle the whole response in one ‘event’ rather than having to reconstruct the buffer or worse, not know if the whole frame was received or not.
The requests and responses aren’t size limited rather time limited to ~ 8 seconds for a whole request response transaction. If the Raw Socket flow was used, this RESTful timeout doesn’t apply.
Currently for this to work we are waiting on the RAW socket feature support to be added to the cloud. Hoping we get this out soon as well!
Nope. After more than a year waiting for a response, I think it’s safe to say it’s never going to happen.
(www.rboyapps.com - Making SmartThings Easy!)
One last shot, @firstname.lastname@example.org - do you think this can be done? It has basic support using LAN protocol, do you think it could be enhanced to provide a raw return value from the other end of the socket?
Another feature in this same genre that would be nice is an XMPP library that could be used from a smart app to talk with a device on my local network. I am sure that is not a simple request either but I do have a couple of devices on my local network that talk XMPP but today I have to communicate with an app running on my mac that act as a proxy between my ST app and the XMPP device. With a raw TCP socket i could probably do what I need but the actual protocol support would be even better!
Would you care to elaborate as to why it’s not this simple? Can you not just allow us to use the built in java socket object, instead of throwing a security exception? I understand there is some complexity for the simulator, but that seems simple enough to just mock the socket and send it to the UI?
Hi @geko would you mind sharing your complete hubCommand code? There’s plenty of people around struggling, apparently, like me. I’m also trying to send a tcp packet. So far I have a workaround with an arduino with ethernet shield and web server so I could send httpGet() commands. But if I could send raw tcp instead directly to my devices that’d be really useful. Mind sending your code? So far I can’t send any packet via the HubAction